How to convert your app in Multilanguage in Business Central

In this post, we are going to configure our extension code to make it multi-language.

The first thing we need to do is go to our app.json

and let’s add line 17 the following key value

"features": ["TranslationFile","GenerateCaptions"]

This enables us that the next time we compile it will generate an .xlf file that will be the one we will use to create our translations.

Code Customer Page Card

For this explanation, we will use the following code from this page, where we can see that we have 3 labels or captions.

Transalation File

To generate the translation file it is enough to compile with “Shift+Cntrl+b“.By default, the generated file will have the following format: NameExtension.g.xlf.

It is necessary to change the name of the file because every time we compile it will be regenerated and we will lose our changes.

CreditLimit.g.xlf

The first step in creating our translation is to set the source and target parameters.

From the CreditLimit.g.xlf file, we can go to line number 3.

<file datatype="xml" source-language="en-US" target-language="en-US" original="CreditLimit">

For this example, our purpose is to create the extension in Spanish Mexico.

So in the target-language we will use es-MX“.

<file datatype="xml" source-language="en-US" target-language="es-MX" original="CreditLimit">

The next step will be to add <target> the New Mexico Spanish translation for each caption.
To keep the code organized it would be advisable to add it below each <source>

For example

<target>¿Está seguro de que desea establecer %1 en %2?</target>

It would be as follows:

        <trans-unit id="PageExtension 713600979 - NamedType 1333961654" size-unit="char" translate="yes" xml:space="preserve" al-object-target="PageExtension 713600979">
          <source>Are you sure that you want to set the %1 to %2?</source>
          <target>¿Está seguro de que desea establecer %1 en %2?</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">PageExtension CreditLimitExtension - NamedType AreYouSureQst</note>
        </trans-unit>

Below we will show an example translation file (with a new name):

CreditLimit.g.es_MX.xlf

Tests

English Version

If we try our extension, the messages will be originally in English:

If we want to change the language, for the example that we have created, in our Business Central we go to Settings and select Spanish Mexico.

Spanish Version

And automatically Business Central will recognize which language to display.

To finish, we can get more information from the official Microsoft link on how to convert our app in multiple languages here.

Also, there is a tool to massively manipulate our labels in various languages called Multilingual app toolkit. more information here.

I hope this has helped you.

Leave a Reply

Your email address will not be published. Required fields are marked *