Dynamic script change for image or other asset

More
5 years 1 month ago #3579 by lhy
hi,i'm the user that leave message for how to localize a videoclip.
1.i know how to localize a string, just with localizedstring i can get the string i want.
But how can i get the image/texture? the example seems always localize through drag a localize component and set the term.
what i want is , is there a way to get a real localized image api like Image Flag = LocalizeManager.GetTransitionToImage("Flag“)just through code. Currently i have to add component to the image which i want to localize and use Image.GetComponent<Localize>().SetTerm(xxx);

2.all the localize component has the language source, it can reference the i2 localization language source asset in the resource folder or localization source in the the scene, but if i reference the language source in the project, it will lose the reference in other machine and auto find the i2 localization language source asset in the resource fold which i didn't want.

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

More
5 years 1 month ago #3582 by Frank

hi,i'm the user that leave message for how to localize a videoclip.
1.i know how to localize a string, just with localizedstring i can get the string i want.
But how can i get the image/texture? the example seems always localize through drag a localize component and set the term.


Terms always store a text as a translation. But depending on what the term time is (Text, Font, Image, etc), then the text is either considered the actual translation text, or the font name, image path, etc.

How those assets are handled depends on whether they are inside a Resources folder, an AssetBundle or just in your Assets folder. Here is more info about this:
inter-illusion.com/assets/I2LocalizationManual/AssetsTab.html

Basically:
- If the asset is in a resources folder, then it uses Resources.Load( LocalizationManager.GetTranslation(..) )
- If is in an AssetBundle, it calls the AssetBundleManager with that name to get the asset.
- Otherwise, it tries finding an asset with that name in either the I2Languages's Assets section or the Localize component References section.

Luckly, there is an easy way to handle all that automatically.
The plugin has a function that given a translation text, will look for the appropiate asset and return it.

So, you can do:
    string translation = LocalizationManager.GetTranslation("My Term");
    Texture2D texture = LocalizationManager.GetTranslatedObject<Texture2D>( translation );

2.all the localize component has the language source, it can reference the i2 localization language source asset in the resource folder or localization source in the the scene, but if i reference the language source in the project, it will lose the reference in other machine and auto find the i2 localization language source asset in the resource fold which i didn't want.


There is no need to reference the I2Languages.asset in a Localize component.
I2Languages.asset is a "Global" source that its always loaded at startup and all Localize component will use it, unless you manually reference another source from your scene. (If the Localize component reference is set to none[null], then it will look for the Term in the Global sources)

Said that, If what you are trying to do is to have more than one global source (e.g. I2Languages.asset, MyTutorialLanguages.asset, etc). The you should add their names to the GlobalSources array in
Assets\I2\Localization\Scripts\Manager\LocalizationManager_Sources.cs line 16
        public static string[] GlobalSources = { "I2Languages", "MyTutorialLanguages" };

That way, both are going to be loaded at startup and be accessible in all your scenes.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The following user(s) said Thank You: lhy

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

Time to create page: 0.146 seconds
Template by JoomlaShine