Localize directly from scripts

More
10 years 6 months ago #80 by crash
Thanks for quick reply.
I have to add namespace to make it work: I2.Loc.ScriptLocalization.Get(Term);

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

More
10 years 5 months ago - 10 years 5 months ago #93 by stupid_n00b
I'm having a tough time getting any strings to come back from the ScriptLocalization function. For example, I have these in my string table:


I have this in my ScriptLocalization function (generated via the editor tool):
public static class ScriptLocalization
	{
		public static string Get( string Term ) { return LocalizationManager.GetTermTranslation(Term); }


		public static string kLang_Buttons_Buy 		{ get{ return Get ("kLang_Buttons_Buy"); } }
		public static string kLang_Buttons_Cancel 		{ get{ return Get ("kLang_Buttons_Cancel"); } }

	}

But both of these return empty (null) strings when used in code:
Debug.Log (ScriptLocalization.Get("kLang_Buttons_Buy"));
Debug.Log (ScriptLocalization.kLang_Buttons_Buy);

I'm probably missing a setting somewhere? I have the I2 folder in the root of my Assets directory.
Last edit: 10 years 5 months ago by stupid_n00b.

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

More
10 years 5 months ago #94 by Frank
If those function return null it means that the term was not found in the loaded Language Sources.

Where are you storing your terms. Is it in a source inside the scene or in the I2Languages.prefab ?

Is the language set to any of the valid languages? (e.g. "English (United States)" and not just "English").

If you localize any other label/object using the Localize component and not changing the localization from the script, does it localize fine with those same terms?

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

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

More
10 years 5 months ago #95 by stupid_n00b
It looks like it works if I have a label with a Localize script attached to it active in the scene before I call it anywhere from code, so yes, it wasn't initializing the language. That's a fine workaround for what I needed. Thanks!

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

Time to create page: 0.222 seconds
Template by JoomlaShine