i18n-l10n-editor is a Visual Studio Code extension to easily edit your i18n and l10n translations files. This extensions is built on the work by Thibault Vanderseypen, Innwin and Isaudon.
i18n-l10n-editor can be used in three ways:
-
Click the i18n/l10n Editor Button on the status bar. This will search for any l10n.yaml file and then open the translations from these files. You do not have to set i18n-l10n-editor.workspaceFolders for this to work. But you should set a list of supported folders in i18n-l10n-editor.supportedFolders so the editor can search for translation files in your project.
-
Right click on a folder that contains translations, such as i18n or l10n and select i18n/l10n Editor from the context menu.
-
In any .dart file select any text including the quotes the from the light bulb on the left choose Add text to i18n/l10n Editor. This show some dialog boxed to confirm vales and then add the values to the translations.
- This will save all opened translations.
- This will add a new key to the selected folder, or all folders.
- This will create a new translation file. if i18n-l10n-editor.autoTranslateNewLanguage is enabled the it will translate the new file from the default translation file. This will save all translations before creating the new file.
- Switch between table and tree views.
- This will copy the selected key to other translation folders. If the key doesn't exist in the folder then it will add it and set it to the default translation text. If the key does exist and is empty, it will not overwrite it.
- This will translate the default translation text to all translations within the folder.
- This will translate the default language to the select language.
- This will copy the default translation text to all translations within the folder without translating the text. This is good to copy your descriptions across.
NOTE for translations to work your require i18n-l10n-editor.translationService, i18n-l10n-editor.translationServiceApiKey and i18n-l10n-editor.translationServiceApiRegion to be set or the Translation Specific settings. Currently we only support the following translations services Microsoft Translation, Google Translation and Amazon Translation. See Language Documentation for a list of supported language codes for each service.
These are typical settings for the YAML file used to configure Internationalization. This is the proffered method of setup.
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
untranslated-messages-file: missing.log
nullable-getter: false
You can also use the pubspec.yaml file to configure Internationalization.
flutter_intl:
enabled: true
arb-dir: lib/l10n/arb
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
untranslated-messages-file: missing.log
nullable-getter: false
To access the settings click Code -> Settings on a Mac or File Preference on Windows. In the setting click Extensions and the scroll down to Localization Internationalization Editor
- i18n-l10n-editor.forceKeyUPPERCASE
- Forces the keys to UPPERCASE (deprecated). If true this will force the keys to UPPERCASE. The default value is false
i18n-l10n-editor.forceKeyUPPERCASE: false
- Forces the keys to UPPERCASE (deprecated). If true this will force the keys to UPPERCASE. The default value is false
- i18n-l10n-editor.keyCaseStyle
- This sets how to write keys to the files valid methods are no change, camelCase, Capalize, lowercase, UPPERCASE. Both camelCase and Capalize requires spaces when typing the key. The default value is no change.
i18n-l10n-editor.keyCaseStyle: "no change"
- This sets how to write keys to the files valid methods are no change, camelCase, Capalize, lowercase, UPPERCASE. Both camelCase and Capalize requires spaces when typing the key. The default value is no change.
- i18n-l10n-editor.sortKeyTogether
- Sort files and the editor so that key and @key will be kept together. The default value is true.
i18n-l10n-editor.sortKeyTogether: true
- Sort files and the editor so that key and @key will be kept together. The default value is true.
- i18n-l10n-editor.executeFlutterGen
- Execute flutter gen-l10n when the translations are saved. the requires a l10n.yaml file to work.
i18n-l10n-editor.executeFlutterGen: true
- Execute flutter gen-l10n when the translations are saved. the requires a l10n.yaml file to work.
- i18n-l10n-editor.autoTranslateNewLanguage
- This will auto translate any new translations files added to the editor. It requires the translations to be added. The default value is false.
i18n-l10n-editor.autoTranslateNewLanguage: false
- This will auto translate any new translations files added to the editor. It requires the translations to be added. The default value is false.
- i18n-l10n-editor.defaultLanguage
- Used when no default language is specified in translation files otherwise the first file found is used. The default vale is en.
i18n-l10n-editor.defaultLanguage: "en"
- Used when no default language is specified in translation files otherwise the first file found is used. The default vale is en.
- i18n-l10n-editor.translationService
- Specified which translation service to use (Only Microsoft translator is currently available). The default value is blank.
i18n-l10n-editor.translationService: ""
- Specified which translation service to use (Only Microsoft translator is currently available). The default value is blank.
- i18n-l10n-editor.translationServiceApiKey
- Api key used by the translation service. Copy this from the Key Generation page. Leave this blank if you wish to switch between Translation Services.
i18n-l10n-editor.translationServiceApiKey: ""
- Api key used by the translation service. Copy this from the Key Generation page. Leave this blank if you wish to switch between Translation Services.
- i18n-l10n-editor.translationServiceApiSecret
- Api secret used by the translation service. Copy this from the Key Generation page. Leave this blank if you wish to switch between Translation Services.
i18n-l10n-editor.translationServiceApiSecret: ""
- Api secret used by the translation service. Copy this from the Key Generation page. Leave this blank if you wish to switch between Translation Services.
- i18n-l10n-editor.translationServiceApiRegion
- Api region used by the translation service. Copy this from the Key Generation page. Leave this blank if you wish to switch between Translation Services.
i18n-l10n-editor.translationServiceApiRegion: ""
- Api region used by the translation service. Copy this from the Key Generation page. Leave this blank if you wish to switch between Translation Services.
- i18n-l10n-editor.translationServiceAmazon
- Settings for the Amazon Translate APIs ["apiKey","apiSecret","apiRegion"]. Copy this from the Key Generation page.
i18n-l10n-editor.translationServiceAmazon: ["","",""]
- Settings for the Amazon Translate APIs ["apiKey","apiSecret","apiRegion"]. Copy this from the Key Generation page.
- i18n-l10n-editor.translationServiceGoogle
- Settings for the Google Translate APIs ["apiKey","apiSecret","ProjectID"]. Copy this from the Key Generation page.
i18n-l10n-editor.translationServiceGoogle: ["","",""]
- Settings for the Google Translate APIs ["apiKey","apiSecret","ProjectID"]. Copy this from the Key Generation page.
- i18n-l10n-editor.translationServiceMicrosoft
- Settings for the Microsoft Translate APIs ["apiKey","apiSecret (blank)","apiRegion"]. Copy this from the Key Generation page.
i18n-l10n-editor.translationServiceMicrosoft["","",""]
- Settings for the Microsoft Translate APIs ["apiKey","apiSecret (blank)","apiRegion"]. Copy this from the Key Generation page.
- 18n-l10n-editor.jsonSpace
- A String or Number that's used to insert white space into the output JSON. The default value is 2.
18n-l10n-editor.jsonSpace: 2
- A String or Number that's used to insert white space into the output JSON. The default value is 2.
- i18n-l10n-editor.keySeparator
- String to separate keys, or false if no separator is preferred. The default value is ".".
i18n-l10n-editor.keySeparator: "."
- i18n-l10n-editor.lineEnding
- String used to signify the end of a line. The default value is \n.
i18n-l10n-editor.lineEnding: "\\n"
- String used to signify the end of a line. The default value is \n.
- *i18n-l10n-editor.supportedYamlFiles
- An array of YAML file names that's used to search for configuration settings.
i18n-l10n-editor.supportedYamlFiles: ["i18n.yaml","l10n.yaml","r13n.yaml","pubspec.yaml"]
- An array of YAML file names that's used to search for configuration settings.
- i18n-l10n-editor.supportedFolders
- An array of folder names that's used to open the extension through the right click (restart required after changing the value). The default values are l10n and l18n.
i18n-l10n-editor.supportedFolders: ["l10n","i18n","r13n"]
- An array of folder names that's used to open the extension through the right click (restart required after changing the value). The default values are l10n and l18n.
- i18n-l10n-editor.supportedExtensions
- An array of file extension to check when loading the editor. If no file exists then the first one is used by default (restart required after changing the value). The default values are arb and json.
i18n-l10n-editor.supportedExtensions: ["arb","json"]
- An array of file extension to check when loading the editor. If no file exists then the first one is used by default (restart required after changing the value). The default values are arb and json.
- i18n-l10n-editor.workspaceFolders
- An array of objects to specify which folders are used to manage your translations (deprecated). This is only used if the editor can not find any translation folders. The default value is blank.
i18n-l10n-editor.workspaceFolders: []
- An array of objects to specify which folders are used to manage your translations (deprecated). This is only used if the editor can not find any translation folders. The default value is blank.
- i18n-l10n-editor.substitutionText
- A String to replace text when highlighting text in a Dart editor. To have this work you should place the following in your build methods
final l10n = AppLocalizations.of(context);
This will allow the editor to placel10n.exampleKey
in your files.i18n-l10n-editor.substitutionText: "l10n"
- A String to replace text when highlighting text in a Dart editor. To have this work you should place the following in your build methods
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context);
return Builder(...
When switching between languages it is possible that some translations will fail due language codes. For example Microsoft uses zh-Hant where Amazon uses zh-TW. On top of this there are differences in words used. It is best to stick with one Translation Service for the duration of a project.
- Amazon Translations Languages
- Amazon Translation Regions
- Google Translations Languages
- Microsoft Translation Languages
I have now completed everything i wanted to by taking over this project and feel that there isn't much more i can add. Please submit feature request to my GitHub if you feel you need them to be added.
i18n/l10n Editor is free for non-commercial usage. If you wish to use it for commercial purposes then I would appreciate a donation of $US5/user PayPal.Me or Buy Me a Coffee. This extension can save you hours doing translations manual and a small donation would be welcomed.
Previous authors include Thibault Vanderseypen, Innwin and Isaudon