Dynamic loading of Language Sources

More
2 weeks 5 days ago #4076 by tombodyswaps
I'm a bit unclear on what the process is for loading Language Sources at runtime.
I see you can use the Language Source game object, but that's not ideal for me I'd like to load it directly from a Resource/AssetBundle which I see mentioned is possible. Any quick tips? What's the correct API calls?

Please Log in or Create an account to join the conversation.

More
2 weeks 5 days ago #4077 by tombodyswaps
I did actually do this...
LocalizationManager.Sources.Add((activeScenario.localisation as LanguageSourceAsset).mSource);

Basically activeScenario is a scriptable object which holds a reference to the LanguageSourceAsset which I load in.. It seems to work but is that legit? what should I do about clean up after I don't need it? Just set it to null??

Please Log in or Create an account to join the conversation.

More
2 weeks 2 days ago #4082 by tombodyswaps
Actually I've not got this working properly yet.

So I have an LanguageSourceAsset, named I2Languages the global one, in my Resources folder which works fine.

But then I want to load at runtime in another LanguageSourceAsset from my resources which contains strings just for a section of the app, (which will be unloaded later).
However the GetTranslation() function only find strings in the main one. It doesn't seem to traverse the dictionaries of the other Sources even though I added it to the list.

Can you please advise on how to acheive this, because its mentioned as possible in your documentation, but no code example given.

I tried this:
LanguageSourceData sourceData = (localisation as LanguageSourceAsset).mSource;
sourceData.UpdateDictionary();
LocalizationManager.Sources.Add(sourceData);
LocalizationManager.LocalizeAll();

But doesn't seem to be working properly.

I don't want to have to add a GameObject and a Language Source component to the scene as the rest of the architecture is all data driven.

Thanks!

Please Log in or Create an account to join the conversation.

More
2 weeks 2 days ago #4083 by tombodyswaps
Ha, okay talking to myself. I found the problem.

If you set the LanguageSource Missing Translation field to "Show Term" instead of "Fallback", then it won't iterate through the other Sources if it can't find the term. Which makes sense I guess.
However seeing the original term is a useful debug technique for spotting missing translations (because all of mine are driven through scripts) rather than seeing no text.

Any chance at some point adding a function to Show Term on missing translation, but *ONLY* after its gone through all the available sources?

Thanks

Please Log in or Create an account to join the conversation.

Time to create page: 1.147 seconds
Template by JoomlaShine