Dynamic loading of Language Sources
- tombodyswaps
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
4 years 9 months ago #4076
by tombodyswaps
Dynamic loading of Language Sources was created 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?
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.
- tombodyswaps
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
4 years 9 months ago #4077
by tombodyswaps
Replied by tombodyswaps on topic Dynamic loading of Language Sources
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??
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.
- tombodyswaps
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
4 years 9 months ago #4082
by tombodyswaps
Replied by tombodyswaps on topic Dynamic loading of Language Sources
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!
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.
- tombodyswaps
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
4 years 9 months ago #4083
by tombodyswaps
Replied by tombodyswaps on topic Dynamic loading of Language Sources
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
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: 0.121 seconds