Skip to content

LocalizationManager

Benedikt Hensen edited this page Nov 27, 2018 · 4 revisions

Localization Manager

The framework supports different languages due to the Localization Manager. It can automatically change the keyboard-layout and the text strings in the program.

All data for the Localization Manager are stored in the folder Assets/Resources/values

String Translation

Strings are stored in a file strings-xx.json where xx is the code for the language. The code for the individual languages can be set in the method GetLanguageCode. The string file consists of key-value pairs. The value is the translated string which will be shown if this language is selected. The key can be used anywhere in the application. In order to define translatable strings in the code, call the static method LocalizationManager.ResolveString(key). This method searches the key in the strings file of the selected language. If the key does not exist, the unchanged key is returned.

Since the method ResoleString returns the key if it does not exist in the string file, it should be ensured that the user can also understand the key. The existing string files solve this by using the English translation as the key. This way the user still sees the English string if there are missing translations. Any keys which do not have a translation are also logged as warnings. When debugging the application in the Unity Editor, the warnings contain a list of all keys which could not be translated. This list can be used to add the new translations.

Keyboard Layout

The keyboard is also altered depending on the selected language. The data for the keyboard are saved in the file keyboardLayout-xx.json where xx is again the language code. The file contains an array which assigns a letter to a key on the keyboard. The keys are iterated left to right and top to bottom.

It is recommended to create new keyboard layouts by altering a copy of an existing layout. This way, it is clear which key is targeted by an array element.

The LocalizationManager checks if the number of keys on the 3D keyboard equal the number of provided array elements.

Clone this wiki locally