Skip to content

Translations

Niels Steenbeek edited this page Feb 5, 2021 · 10 revisions

Translations

Translation will use resx files. That is the recommended way since it uses Xrm.Utility.getResourceString under the hood. When running the extractTranslations command a src/translation/locales/locales.resx file will be generated if not there. Please duplicate and rename for each required language to filenames like locales.1033.resx. When running the extractTranslations command again, all resx file keys will be updated.

Resources

When a project is created it contains resources for translations:

  1. src/translation/Translation.ts
  2. Command/script for extraction

Dependencies

CLI Command 'extractTranslations' extracts all translation from project TypeScript files. The TypeScript files using translations, needs to specify all translation files as dependencies. The Deploy command will do this job for you.

Extraction

Running the extractTranslations command

hso-d365 extractTranslations

will extract translations from all Translation.translate invocations and puts them in src/translation/locales folder.

Example

import {Translation} from '../translation/Translation';

export class EntityForm {
    static async onLoad(executionContext: Xrm.Events.EventContext): Promise<void> {
        console.log(Translation.translate('this will be translated');
    }
}
Clone this wiki locally