Internationalization

The Zopio CLI provides robust tools for managing translations and locales in your zopio application. This page covers how to use the CLI to add, update, and manage translations.

Directory Structure

The Zopio framework uses both next-international and next-intl for internationalization, which requires translations to be stored in two locations:

├─ locales/
│  ├─ en/
│  │  └─ common.json
│  └─ tr/
│     └─ common.json
├─ dictionaries/
│  ├─ en/
│  │  └─ common.json
│  └─ tr/
│     └─ common.json
├─ i18nConfig.ts
└─ languine.json

i18n Command

The i18n command helps you manage translations and locales in your zopio application.

zopio i18n [options]

Options

  • --add <locale> - Add a new locale
  • --remove <locale> - Remove a locale
  • --extract - Extract translation keys from source files
  • --sync - Synchronize translation files across locales
  • --check - Check for missing translations
  • --default <locale> - Set the default locale

Examples

zopio i18n --add tr

Supported Locales

The Zopio CLI supports the following locales out of the box:

  • en - English (default)
  • tr - Turkish
  • es - Spanish
  • de - German

You can add support for additional locales using the i18n --add command.

Configuration

The internationalization system is configured through two files:

i18nConfig.ts

// i18nConfig.ts
export const i18nConfig = {
  defaultLocale: 'en',
  locales: ['en', 'tr', 'es', 'de'],
  localeDetection: true,
  localePrefix: 'always'
};

languine.json

// languine.json
{
  "defaultLocale": "en",
  "supportedLocales": ["en", "tr", "es", "de"],
  "fallbackLocale": "en",
  "namespaces": ["common", "auth", "dashboard"],
  "translationDirs": [
    "dictionaries",
    "locales"
  ]
}

Using Translations in Components

The Zopio CLI generates components with internationalization support built-in:

    Translation Management

    The Zopio CLI provides several commands to help you manage translations:

    Extract Translation Keys

    zopio i18n --extract
    

    This command scans your source files for translation keys and adds them to your translation files.

    Synchronize Translations

    zopio i18n --sync
    

    This command ensures that all translation files have the same keys across all locales.

    Check for Missing Translations

    zopio i18n --check
    

    This command identifies missing translations in your locale files.