Docs

Configuration

The Polygot CLI uses a JSON configuration file (polygot.config.json) to store the Polygot project information. To be able to function properly, the Polygot CLI has to know which project it is bound to, where the source localization files are located, and where to store the localization files for the target languages.

Initialize the project

  1. In the root directory of your code project, run the "init" command
    polygot init
    
  2. Follow the prompt instructions
    • select your Polygot project
    • enter the localization of your source i18n file(s): you can use glob patterns to be able to target several files
    • enter the localization of the translated files: here you can use tags in order for Polygot to be able to rebuild the name of the generated files (see the tags table bellow)
    • if you need it, you can add an additional configuration

Target file pattern tags

TagDescription
%lang%Will be replaced by the lang of the translated file
%name%Will be replaced by the source file name, without its extension
%ext%Will be replaced by the extension of the source file

Sample configuration file

Here is a sample Polygot CLI configuration file.

{
  "projectId": 87,
  "i18nConfigs": [
    {
      "source": "src/locales/en.js",
      "target": "src/locales/%lang%.%ext%"
    },
    {
      "source": "src/packages/ui/locales/en/*",
      "target": "src/packages/ui/locales/%lang%/%name%.%ext%"
    }
  ]
}

Within the directory in which this file is located, the CLI is bound to the project identified by the id 87. 2 configurations have been set up:

  • the src/locales/en.json source file translations will be saved under src/locales/%lang%.%ext% (for instance src/locales/fr.json)
  • the src/packages/ui/locales/en/* source file translations will be saved under src/packages/ui/locales/%lang%/%name%.%ext% (for instance src/packages/ui/locales/fr/home.json, src/packages/ui/locales/fr/help.json, src/packages/ui/locales/es/home.json)