MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

How to support multiple translations in different UI and API?



  • My modules would like to support multiple languages (e.g. zh-hk and zh-tw). But actually both language uses the same set of language (Traditional Chinese).

    UI

    I could support both language in the following function:

      getTranslations: function () {
        return {
          ...
          "zh-hk": "translations/zh-tw.json"
          "zh-tw": "translations/zh-tw.json"
        };
    

    Is it possible that I could pre-map zh-hk to zh-tw so that I only need to keepzh-tw in getTranslations?

    API

    The API also returned the localized value based on the language parameters. Therefore I would like to convert zh-hk and zh-tw into zh-hant required by the API (in two different lines). Currently I am doing the conversion in a hard-code way. Is it possible that I could pre-map zh-hk to zh-tw so that I could translatezh-tw into zh-hant in the API code?


Log in to reply