# Supporting multiple languages

To support multiple languages in your mission, do the following:

  1. Define a data.translation table for each language you want to support beyond the default language
  2. Populate the data.translation.Language table with the keys being the default language strings, and the values being the string to use for the specific language.

local:$MISSION_LANGUAGE contains the currently selected language name. If it is null or undefined, then the default language will be used without attempting to swap to any other language.

Keys that aren't found in the target language will be rendered in the default language.

Examples:

"data":{
  "translation": {
    "French": {
      "hello world": "Bonjour le monde",
      "hello world {0}": "Bonjour le monde ({0})"
    },
    "German": {
      "hello world": "Hallo Welt",
      "hello world {0}": "Hallo Welt ({0})"
    }
  }
},
...
{"set_message": {"text":"hello world"}},
{"set_objective_title": "hello world"},

# Translation test program

{
  "title": "Translation Test Program",
  "data":{
    "translation": {
      "French": {
        "hello world": "Bonjour le monde",
        "hello world {0}": "Bonjour le monde ({0})"
      },
      "German": {
        "hello world": "Hallo Welt",
        "hello world {0}": "Hallo Welt ({0})"
      }
    }
  },
  "briefing": [

    {"text":"Language selection:"},
    {"buttonbar":[
      {
        "title":"English (default)", 
        "commands":[ {"set": {"local":"$MISSION_LANGUAGE"}, "value": null} ],
        "select_condition":{"require":{"local":"$MISSION_LANGUAGE"}, "eq":null}
      },
      {
        "title":"French", 
        "commands":[ {"set": {"local":"$MISSION_LANGUAGE"}, "value": "French"} ],
        "select_condition":{"require":{"local":"$MISSION_LANGUAGE"}, "eq":"French"}
      },
      {
        "title":"German", 
        "commands":[ {"set": {"local":"$MISSION_LANGUAGE"}, "value": "German"} ],
        "select_condition":{"require":{"local":"$MISSION_LANGUAGE"}, "eq":"German"}
      }
    ]},
    {"text":"hello world"},
    {"text":{"text":"hello world {0}", "params":[ 99 ]}}
  ],
  "objectives": [
    {
      "title": "Done",
      "commands": [
        
        {"#comment":"adding a loop here only because it won't re-evaluate ever otherwise"},
        {"while":1, "eq":1, "do":[
          {"set_message": {"text":"hello world"}},
          {"set_objective_title": "hello world"},
          {"sleep":1}
        ]},

        
        {"sleep": "forever"}
      ]
    }
  ]
}