MicroStrategy ONE

Internationalization (i18n) of the React Format Panel

This feature is available starting in MicroStrategy 2021 Update 3.

There are two approaches to displaying translated text in the Format panel based on user location or settings:

Use Existing Translations

If the translated text exists in another visualization and you have direct access to the code, it is possible to use the same translated text. The important thing to remember is the context of the text. If the context of the existing translated text is different, it is better to create a custom translation. The structure of the code is shown below.

Copy
{ desc: <descId>, name: <defaultName> }

descId The ID of the translated text.

defaultName The name used to identify the text. If descId is not defined, the name is used by default.

The example below shows how to implement translations for a text component:

Copy
{
     tagName: "Text",
     text: { desc: 9738, name: "Area" }
}

Add New Custom Translations

The table below lists all languages supported by custom visualizations.

Language

Language Code

Country Code
Chinese (Simplified) zh CN
Chinese (Traditional) zh

TW

Danish (Denmark) da DK
Deutsch de

DE

Dutch (Netherlands) nl NL
English (UK) en

GB

English (US) en US
French (Belgium) fr

BE

French (France) fr FR
French (Switzerland) fr

CH

German (Switzerland) de CH
Italian (Italy) it

IT

Italian (Switzerland) it CH

Japanese

ja

JP

Korean ko KR

Polish

pl

PL

Portuguese (Brazil) pt sBR

Russian

ru

RU

Spanish (Spain) es ES

Swedish (Sweden)

sv

SE

Follow the steps below to add new custom translated text.

  1. Create the MessagesBundle*.properties files for all languages to be supported. The naming conventions for the files are shown below.

    1. MessagesBundle_(Language code)_(Country code).properties

    2. MessagesBundle_(Language code).properties

    3. MessagesBundle.properties

    Let's use an example to explain the logic. To support English (UK):

    1. The plugin attempts to locate MessagesBundle_en_GB.properties. If the file exists, the localized string is used.

    2. If MessagesBundle_en_GB.properties does not exist, the plugin looks for MessagesBundle_en.properties. If the file exists, the localized string is used

    3. If MessagesBundle_en.properties does not exist, the plugin looks for MessagesBundle.properties. If the file exists, the localized string is used.

    If there is no proper file provided, the default text introduced in the code is used. If there is text without a reference to a corresponding translation, it appears in the dashboard surrounded by asterisks (for example, *Attribute*).

    For the sample plugin there is no need to create all the files from scratch. All fully prepared files can be found under SampleViz/i18n. The only requirement is to copy the files from this location to YourPluginFolder/WEB-INF/classes/resources.

  2. To add new i18n strings, create MessagesBundle files under YourPluginFolder/WEB-INF/classes/resources, if they do not exist.

  3. Add all strings in the correct format to each of the MessagesBundle*.properties files.

    Copy
    <prefix>.<string_id>=<string_content>

    prefix Differentiates the strings used in this custom visualizations from others. Follow standard naming conventions by using the custom visualization name here.

    string_id The ID used to identify the string. The ID should be unique within a custom visualization. Follow standard naming conventions by using incremental numbers.

    string_content The localized string for each language.

    The example below uses the sample plugin.

    Copy
    SampleViz.10=Attribute
    SampleViz.11=Show attribute
    SampleViz.12=Metric
    SampleViz.13=Show metric
  4. Restart the Tomcat Web server.

  5. The mstrmojo.requiresDescsWPrefix() function is then used to load the translations. Add unique identifiers to this function inside the main visName.js file, where visName is the name of the visualization. Place this function call after any import statements and before the plot() function. This allows the code to run first, so the descriptors are loaded before they are needed. Using mojo style internationalization (as described below) while having unloaded descriptors results in a 100ms request to fetch them. Several of these requests cause a noticeable delay when loading the visualization for the first time.

    The mstrmojo.requiresDescsWPrefix() function requires arguments for the prefix name and all used string IDs, as shown below.

    Copy
    mstrmojo.requiresDescsWPrefix("SampleViz.", 10, 11, 12, 13);
  6. Add translations to the destination file using the following template.

    Copy
    mstrmojo.descP('<prefix>.', '<string_id >', '<string_content>')

    The example below shows a descriptor usage for a checkbox component.

    Copy
    {
        tagName: "Checkbox",
        key: PROPERTIES_ENUM.SHOW_ATTRIBUTE,
        text: mstrmojo.descP("SampleViz.", "11", "Show attribute"),
    },