- Home /
Multi Language app
Hello, I am trying to figure out the best way of adding multi language to my app, i was thinking of adding all buttons/UI text to dictionarys, and use the language as key, or having different xml/txt and use the current language for path for each xml/txt. can i get some advice? maybe suggest a third way of doing this? is there any default way of doing this?
I would suggest using a database, sql, sqlite whatever that suits you but due to how much a hassle it is to add database system without plugins, I will not post as an answer.
Anyhow, the schema would be ( id, lang1, lang2, lang3....) and since there are a lot of external tools to view and edit such db (using excel importer would also work), once setup, its much more efficient.
Answer by Pangamini · Jun 25, 2019 at 08:41 AM
What I did is: I have folders (in streaming assets, so languages can be added in build) for each language, and these contain a key=value dictionary files. On runtime, a selected language file is loaded (and actual Collections.Dictionary created). In code, I have a language class that lets me either find a value for the key, or replace key markers in a text (which is an extra feature you may not need) Then I have a UI script I place under UI.Text, containing the key. It's hooked to the Language's change callback/event, so when a new language is loaded on runtime, the text of the UI is changed immediately.
i ended up using this method, my app was using texttospeech so changing the text with the dictionary key ended up being the by far fastest way of coding it.
Answer by Kennai · Jun 25, 2019 at 08:19 AM
Hello, @xxmariofer!
I think that way with xml/txt is fine! something like
text1=Play
text2=Exit
text3=Press Play to start
Or another way - create scriptable object with attributes and then fill it.
One nice bonus is that you can create different scriptable objects for different stuff. Like one scriptable object for text UI in scene1, then another scriptable object for text UI in scene2 and so on. It would be easy to edit later. Also you can organize it like folders in your project!
[language]
-english
--scene1
---UI
---Quests
--scene2
---UI
---Quests
and so on
Your answer
