- Home /
What is best practice for translation handling?
Hi!
There are quite a few concepts out there dealing with localization... for several years i've been using my own that i felt somewhat happy with back in the good old days of Actionscript 2. As always: it works somehow, but there's always chance for improvement.
Basically i'm using 2 xml files. One stores the index of strings and the other one holds the actual strings, one file per language. On program start the default language file is being parsed and written to dictionaries. When i need a string it's taken from the dictionaries. When i change the language in the application i'm loading the next language file.
Do you think it would be better to just read the strings from file when i need them?
Does it impact performance or memory consumption too much when i transcribe all the strings to Dictionary? Currently my largest XML file was about 240kb with about 3500 strings, some of them containing about 500 words.
My concern in using a "po" style system (like here: http://wiki.unity3d.com/index.php?title=TextManager) are the resulting IDs. It just doesn't "feel" right to have a 2000 character long identifier to look up a translation. Am i worrying too much or getting something wrong?
Thanks in advance for your views, opinion, advice, ...
I agree that having two large files is kind of a heavy setup. The key's should be more like a reference than the full translation in some cases.
I made a simplified translation system you can try out: https://github.com/camsjams/i18n-unity-csharp
Hi.
I think it's better to load it all at once. Reading those 240kb X$$anonymous$$L may take a few milliseconds, but it's only done once at startup. If you load your strings 'on demand' you may have lots of separate file reads, which usually costs much more. Also, if you ever need to access those texts remotly over some network, you would generate a lot of round trips.
Those 240kb in the xml file should consume a bit less memory in your dictionary, since it's the same strings (assu$$anonymous$$g the encoding is the same) - $$anonymous$$us some xml tags. And dictionaries are a pretty fast way to go for unsorted data access with an id. That should be fine.
I think you are worrying too much. Did you already finish the rest of your game? :D Usually it's not worth thinking about saving those 200kb of memory, when all you have to do is scale down a single texture and can save 5 times as much.
woops ... that question was from last year? never $$anonymous$$d.
Your answer
Follow this Question
Related Questions
How can I internationalize(I18n) a unity 3D project? 3 Answers
Language/translation connector to Unity - will it be useful? 0 Answers
How can I determine the current locale, or at least the currency symbol? 4 Answers
IOS App Display Name Internationalizat 1 Answer
Some foreign characters disappear on Android, what should I do? 0 Answers