Skip to content

Roman-Lo/vscode-ng-i18n-editor

Repository files navigation

Anglar I18n Editor for VSCode (vscode-ng-i18n-editor)

This extension provides an editor for Angular generated xliff file. If you're struggling handle the xliff files that generated by AngularCLI, this extension might be helpful for you.

Features

Translation Editor

This extension provides a friendly to use editor for users to translate their apps.

1. Save and Lock Your Translation

After you translated one trans unit, you can click ctrl + enter to save and lock (signed-off) your translation.

Overview

Translations that mark as signed-off could not be edit in the editor, unless you unlock them.

2. Reveal Code Context

The code context shows the location where the translation will be apply to.

Reveal Code Context

This will help you write better translations.

Translation Memory (TM)

Translation memory is to store your tranlation history and will give you suggestion for your transunits.

This feature is on the roadmap but not yet started.

Requirements

This extension will only be activated when the extension setting file is under your workspace root directory. Make sure you place the .ngI18nconfig file correctly.

Extension Settings

Extension setting is a json file that placed in the root directory of the workspace, using the name .ngI18nconfig (case sensitive). The following is the configuration options:

Path Object Type Description
locales string[] The locales setting accepts one ore more target locales that your application is going to be translated into. See: Locale Setting.
editor object The editor setting is to control the behavior of I18n editor as well as the background task manager. See: Editor Setting
editor.taskConfig object The editor.taskConfig is to control the background task manager, which executes the transunit saving commands. See: Task Config Setting

Locale Setting

The locales setting accepts one ore more target locales that your application is going to be translated into.

{
  "locales": ["zh-CN", "ja-JP"]
}

Editor Setting

The editor setting is to control the behavior of I18n editor as well as the background task manager.

editor.translationSaveOn: 'blur' | 'change' | 'manual'

Three types of trigger type that tell the editor when to save your translation. The default value is blur.

Only support blur by far.

editor.messageLocations: string[]

The message locations is the location collection for the Angular Compiler extracted xliff files. They should ends with .xliff or .xlf.

{
  "editor": {
    "messageLocations": ["src/locale/messages.xlf"]
  }
}

editor.translationFileNamePattern: string

The pattern to locate the target translation file. The default value is ${name}(${lang}-${region}).

  • ${name}: the source xliff file name;
  • ${lang}: the target language;
  • ${region}: the region where the language in use.

${lang} and ${region} is the consist parts of LCID

editor.mode: 'default' | 'target-file'

Editor mode.

  • The default mode:

    Use the xliff specify in the messageLocations as source and auto generate the target translation xliff based on the given translationFileNamePattern;

  • The target-file mode:

    Edit directly on the target xliff (based on the messageLocations and the given translationFileNamePattern)

editor.emptyTranslationHandling: 'delete' | 'keep' | 'fallback-to-source'

Determine how to handle empty translation.

  • delete: delete the trans unit in the target xliff when empty;
  • keep: keep the trans unit in the target xliff and mark as need-translation;
  • fallback-to-source: fill the translation target using the source string and mark as need-translation;

When editor is in default mode, this option is set delete as default; When editor is in target-file mode, this option is set fallback-to-source as default;

Task Config Setting

The editor.taskConfig is to control the background task manager, which executes the transunit saving commands.

{
  "editor": {
    "taskConfig": {
      "intervalSeconds": 5,
      "itemEachPack": 10
    }
  }
}
editor.taskConfig.intervalSeconds?: number

The frequency of task checking. Default value is 5.

editor.taskConfig.itemEachPack?: number

The maximum command size for each task execution. Default value is 10.

Translation Memory Setting (tm)

(CURRENTLY NOT AVAILABLE)

Feedback or Issues

If you do like this extension, please give me feedback so I know you are using it. If you do like more features, tell me and we can start a discussion.

If you have any problems, go and fire an issue.

Release Notes

The current version is just build for temporary use. Please verify your translation file before building your application into the target locale.

Contact

roman.the.dev@hotmail.com