Thursday, December 27, 2018

Multilanguage Translation in Dynamics 365 Business Central Extension

Multilingual translation/development made easy in AL

Please see this link Working with Translation Files in details (Source: Microsoft Docs).

Language translation has been facilitated with XLIFF file. XLIFF (XML Localization Interchange File Format) is an XML-based format created to standardize the way localizable data are passed between tools during a localization process and a common format for CAT tool exchange. See more about XLIFF.

Below are simple steps to this walk-through:

Step 1 : Add the below tag in app.json file
"features": [ "TranslationFile" ]

Step 2: Modify as below

Instead of direct message, route it through label.

pageextension 50100 CustomerListExt extends "Customer List"
Msg: label '[Business Central] App published: Hello world';

trigger OnOpenPage();

Step 3: Generate Translation file

Initiate the build command (Ctrl+Shift+B) in Visual Studio Code, it will generate a \Translations folder with the .xlf file that contains all the labels, label properties, and report labels that you are using in the extension. The generated .xlf file can now be translated.

For example my project has a global translation file based on ENU (English - United State).

Step 4: Copy, Paste, Rename & Update the language file

For this demo I have copy the "MyProjectD365BC.g.xlf" file & paste it in same folder, later renamed it as (as per naming convention suggested by Microsoft):

For example, I have copy & renamed the file as: "MyProjectD365BC.en-GB.xlf" for English - UK  & "MyProjectD365BC.zh-TW.xlf" for Chinese Traditional - Taiwan.

I have modified "MyProjectD365BC.zh-TW.xlf" file for target language as zh-TW & translation value. Use Bing Translate or Google Translate to get the Chinese Traditional value.

I have modified "MyProjectD365BC.en-GB.xlf" file for target language as en-GB & translation value. In case of en-GB, I have used Hindi to check the translation.

Save and compile/deploy your extension.

Step 5: Change user setting to see the translated value

Change the user setting for language code (from My Settings):

Select the Language "Chinese (Traditional, Taiwan) from list. Make sure Region must remain in English (United States).

Refresh or open the Customer list, now you can see the Hello World translation in Chinese.

See the changes with en-GB by changing My Setting --> Language to English (United Kingdom)

Refresh or open the Customer list, now you can see the Hello World translation in Hindi (as I have used Hindi translation in en-GB. Due to language characters are in Unicode and set in target caption/label translation, it is showing as it is - Hindi). You may try your own...

Keep exploring & sharing. AL for all...