Skip to content

How Translations Work

Jeffrey Gilliam edited this page Mar 1, 2020 · 8 revisions

SIMRacingApps has the ability to support multiple languages. When looking in the source folder on GitHub, of SIMRacingAppsWebContent, there are 4 folders where translations can be found, "apps", "lib", "nls", and "widgets". The "lib/nls" folder contains the files that are used by all the Apps and Widgets and the "nls" folder has the text for the menu. Translate them first. Also each App or Widget, that displays text, can have its own folder named "nls" under it. In these folders there can be one or more files with the language code embedded in the name. For example, all of them will have at least one file named "text-en.json". To translate this into another language, simply copy the file using the language code, keeping it in the same folder. For example, the German name would be "text-de.json" and Spanish would be "text-es.json".

If are not working with the source code, create the folder structure in the "Documents/SIMRacingApps" folder and the server will look there first. Example: "Documents/SIMRacingApps/widgets/Messages/nls/text-de.json". If you want to help me translate to a particular language, let me know and I will prepare a ZIP file that you can extract into the "Documents/SIMRacingApps" folder. But to get the menu translations to look there first, you need to run the server with the following command from the folder where your exe is stored. Change the server filename to the version you have.

java -Xms256m -Xmx512m -cp "%USERPROFILE%\Documents\SIMRacingApps;SIMRacingAppsServer_1.2_Build_BETA-2017.03.02.exe" com.SIMRacingApps.Server

After copying the file, use notepad (or any text editor), to translate the file. Each file will have the English code word on the left and the translated text on the right. For example:

{
    "HELLO": "Hello"
}

Simply change the text on the right side to translate.

{
    "HELLO": "Hallo"
}

There may be multiple words or phrases in the file, so be careful not to change the formatting. Only change the text on the right that is between the double quotes.

If the translation requires special characters, then you need to use the Unicode escape sequence of "\uXXXX". To find the correct code refer to Unicode-Table. For example to embed a "ä" use \u00e4.

{
    "RELATIVE":       "Abst\u00e4nde/ Relative",
}

It is also possible to create files that are specific for a particular country by adding the country code into the name. For example, "text-en_UK.json".

{
    "TIRE": "Tyre"
}

The files are loaded in the following order and the contents are merged with the one before it. Therefore, you do not need to have all of the words in every file, only the first one. Using this method, it will fall back to the English translation if the word/phrase does not exist in one files loaded after it. After making a change and saving it, simply refresh the browser to see the results. Chrome is the best browser to use. Watch out for the browser caching the previous values. Sometimes Ctrl-F5 can be used to override the cache. The language the browser uses will be the same one that Windows uses. To override the language, connect to the server with the following URL (http://{YourIP}?lang=de) or (http://localhost?lang=de) and the language of your choice.

  1. text-en.json
  2. text-en_US.json
  3. text-{language}.json
  4. text-{language}_{country}.json

Once you are finished translating, consider sending the files back to me so others can enjoy the fruits of your work. I'll be sure to mention your name in the credits. Thank You.