Skip to content
longtomjr edited this page Aug 26, 2016 · 4 revisions

"String.Empty good. Me like. Go do." - Quill18

#Localization

For helping translator, here is a list of current translation with PR number so we can see if they are up to date.

Language Human Translated Translated by Robot PR Number Acceptation
English X #239
German X [#146] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/146)
Spanish X #166
Italian X [#233] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/233)
Kurdish X [#241] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/241)
Finnish X [#183] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/183)
French X [#262] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/262)
Polish X #288
Swedish X [#198] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/198)
European Portuguese X [#196] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/196)
Czech X [#179] (https://github.com/TeamPorcupine/ProjectPorcupine/pull/179)
Afrikaans X #285
Arabic X #285
Bosnian (Latin) X #285
Bulgarian X #285
Catalan X #285
Chinese Simplified X #285
Chinese Traditional X #285
Cantonese X #285
Croatian X #285
Czech X #285
Danish X #285
Dutch X #398
Estonian X #285
Greek X #285
Haitian Creole X #285
Hebrew X #285
Hindi X #285
Hmong Daw X #285
Hungarian X #285
Indonesian X #285
Japanese X #285
Kiswahili X #285
Korean X #285
Latvian X #285
Lithuanian X #285
Malay X #285
Maltese X #285
Yucatec Maya X #285
Norwegian Bokmål X #285
Querétaro Otomi X #285
Persian X #285
Portuguese X #285
Romanian X #285
Russian X #583
Serbian (Cyrillic) X #285
Serbian (Latin) X #285
Slovak X #285
Slovenian X #285
Thai X #285
Turkish X #337

#Using the Localization System There are 2 ways to use the localization system:

1) Add a TextLocalizer to the text you want to localize.

2) Localize via LocalizationTable.GetLocalized(...)

The details on how to use them:

1) TextLocalizer

The TextLocalizer script does the localization stuff for you. It suits most cases. Simply add the script to a UI Text. Then, the text's text should be the key that should be searched for (key=Value). The TextLocalizer will localize automatically in the Start() method (if toggled on, defaults to true) or every time the language gets changed. The property formatValues is an array that contains every value that will be formatted.

For example, the array has a length 1, containing World. The value for the localization key is Hello {0}. The end result will be Hello World.

This array can be changed at any given time, but after changing it the user should manually call TextLocalizer::UpdateText(...). A better way is to call the method without changing the formatValues array because it takes a params string[] formatValues. You can immediately push your new array into that method, since it will update the array automatically.

The UpdateText(...) method has a second version, UpdateTextCustom(...). This will also take a string text, which will automatically change the localization key along with the formatValues.

2) LocalizationTable.GetLocalized(...)

This is the manual, sometimes better way of localizing stuff. How it works:

Every time you want to localize some text, you call LocalizationTable.GetLocalized(...). This will return the localized version of the input string or, if the key doesn't exist, either the key itself or the localized version of the text in the default version, right now this is en_US, based on the Fallback Mode (which is right now ReturnDefaultLanguage).

Some code demonstrating the GetLocalized(...) method:

string key = "hello_world"; //Assuming this key exists, in this case, it doesn't

string[] formatValues = new string[] {"world"}; //Assuming the value contains a single "{0}"

string localized = LocalizationTable.GetLocalized(key, formatValues); //This returns the localized string.

Keep in mind that all the localization classes are in the namespace ProjectPorcupine.Localization.