How to develop multilingual capability in apps using Composer

This blog entry is about developing multilingual capability in apps using the non-paying AppGyver Composer. I describe two approaches. They both make use of App Variables and their use have pros and cons.

Using an App Variable to create a dictionary of embedded words.

  1. Create an App Variable. For example “dictionary”.
  2. In the panel on the right, set the Variable value type to Object.
  3. In the “gear” icon next to Variable value type, select initialize with a value
  4. In the Add new property field, enter dictionary entry name, for example “msOrderSubmitted”. Click the + icon to register the entry. (It is a good idea to name the entry with a starting mnemonic, such as ms for message, hd of heading, etc. It helps recognizing and organizing your entries)
  5. In the main panel, under Dictionary, click on the entry you have just created. In this example msOrderSubmitted.
  6. On the right-hand side panel, under Variable value type, set the value to Object.
  7. In the Add new property field, enter the appropriate language mnemonic (en for English, es for Spanish, etc.). Click the + icon to register the entry
  8. Repeat step 7 to add in as many language mnemonics as you need it
  9. Go back to the central panel and click on Dictionary.
  10. On the panel on the right, scroll down until you see the entry you have just created (msOrderSubmitted)
  11. Ignore the id field. In the other language mnemonic fields, enter the text of the desired message in the appropriate language.
  12. Repeat steps 4-11 for each dictionary term you wish to register
  13. Click the Save button to retain your work

How to use the Dictionary entries

  1. Create an App variable (for example, currentLanguage to store the value of the currently selected language mnemonic (en, es, or the language you choose as current. You can control the content by means of a dropdown),

  2. Wherever you wish to use a dictionary language text entry on an AppGyver screen, select Formula. Enter the following formula: LOOKUP(appVars.dictionary.msOrderSubmitted, appVars.currentLanguage)

Pros

  1. When using a Lookup formula, the dictionary entry is easy to locate. Just type appVars.dictionary. and the list of available terms will appear

Cons

  1. As you add terms, the list rapidly becomes unwieldy and is inconvenient to maintain.
  2. Wherever you view AppVars for reasons unrelated to the dictionary, you need to weed through the dozens of dictionary terms to locate the variable you are looking for. This is really annoying.

Using an App Variable to host an externally created dictionary.

This method consist of the following steps:

  1. Create an App Variable. For example “dictionary”.
  2. In the panel on the right, set the Variable value type to Text.
  3. Outside of AppGyver and using the text editor of your choice, create a dictionary text file with the following format:
    {
    price: {en: “Price”, es: “Precio”},
    amount: {en: “Amount”, es: “Monto”},
    unit: {en: “Unit”, es: “Unidad”},
    total: {en: “Total”, es: “Total”},
    request: {en: “Request”, es: “Pedir”},


    msCreateNewPasswordText: {en: “Save your data in a safe place so you’ll find it later.”, es: “Guarde sus datos en un lugar seguro para que los encuentre mas tarde.”},
    msPasswordValuesDoNotMatch: {en: “Password values do not match.”, es: “Los valores de la contraseña no coinciden”}
    }

How to u.se the Dictionary entries

  1. Create an App variable (for example currentLanguage) to store the value of the currently selected language mnemonic (en, es, or the language you choose as current. You can control the content by means of a dropdown, for example ),
  2. In the Global Canvas, create a workflow by adding a Set App Variable. Set the Variable Name to dictionary. In the Assigned value field, manually copy the contents of the external text dictionary
  3. Wherever you wish to use a dictionary language text entry on an AppGyver screen, select Formula. Enter the following formula: LOOKUP(appVars.dictionary.msOrderSubmitted, appVars.currentLanguage). In this case, there is no automatic recall of dictionary terms after the dot following dictionary. You need to know the exact spelling of the term or the formula will fail.

Pros

  1. It is easy to maintain. Using the external file, you can add as many terms as you need and still be able to control the content of the list.
  2. There is no clutter in the AppVars list.

Cons

  1. When creating the formula, you need to remember the exact spelling of the dictionary term or the formula will fail (there us no “intellisense”)
  2. Whenever you modify the external dictionary file, you need to remember to copy its contents to the App Variable in the Global Canvas.
5 Likes

Nice, thanks for this update