Hi all,
I have a bilingual word game. But I have difficulties with language changes. I play the game in English. I’m at level 25. When I select the German language from the main menu while using English, the game continues at 25 levels if it is at 25 levels. But when the language change is made, if the language change is done for the first time, I want the game to start from 1st level in German. So for two languages, I want to have two separate sections in memory. Has anyone faced such a problem?
Another issue is that when the language is changed, the game needs to be restart. How can I manage language change in a healthy way without restart?
Problem 1: Loading
Wherever you’re tracking player progress, track progress in each language separately. Then when the player decides to continue German or English, whichever one they select loads the level appropriate for the language they selected. This could be as simple as serializing a little class like so:
class PlayerProgress
{
public int englishProgress;
public int germanProgress;
// other languages...
}
That integer could determine which level is loaded.
Problem 2: Localization
This problem is harder than the first. You don’t need to restart: you need all things that change with the selected language to change when a different language level is loaded. All text and images that might need localization should get it. To this end, you need to make sure you have components that manage this complexity for you.
So lets say you have a button with the text “No” or “Nein”: this needs to flip. One simple way to do this is to have a component (LocalizationSetter) to which you supply a string-key from the Inspector which it then uses to look up in a localization dictionary for the current language and the component then sets the localized string to the text for the button and swaps the fonts if necessary. When switching languages, you can re-create the localization dictionary<string, string> by reading from a .csv file or the like where the first column is the key and the others are translations for different languages. So if the key is “No” and the language is English, then it’ll look up the value “No”, whereas if the language is German it’ll get “Nein.” You don’t need all the languages loaded at once, only the current one. When you load the scene, the LocalizationSetters do all the work of making sure the correct language is displayed everywhere.
You should look at localization strategies more broadly that I’ve discussed as you consider your use cases because sometimes it can get tricky. If your project is language-centric then you really need to do localization right, so it’s worth some research.