SetTerm won't update

More
4 years 2 months ago #893 by adamliu
SetTerm won't update was created by adamliu
Hi, I need to change the term in the script but according to this post, the SetTerm() should update the translation automatically. But after I called the SetTerm(), i can only see the change updated in the editor, in the game view nothing changes. How can I solve this issue? Thanks!

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

More
4 years 2 months ago #894 by Frank
Replied by Frank on topic SetTerm won't update
Hi,
Thanks for reporting this issue.

If this is happening to you in version 2.6.0, then its because of a regression introduced by the optimizations made to not localize multiple times when the language changes.
I just uploaded a new beta (2.6.0 b5) that corrects the issue.

You can also fix the issue by replacing the SetTerm function (file Localize.cs, line 269-277) with this one:
		public void SetTerm (string primary, string secondary=null)
		{
			if (!string.IsNullOrEmpty(primary))
				FinalTerm = Term = primary;
			if (!string.IsNullOrEmpty(secondary))
				FinalSecondaryTerm = SecondaryTerm = secondary;

			OnLocalize (true);   //   this was changed to add the <true>
		}

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

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

More
4 years 2 months ago #895 by adamliu
Replied by adamliu on topic SetTerm won't update
Thanks Frank. I'll try the solution and see it fixes my problem. Also, I was using version 2.6.0 b4, and actually the version displayed in the plugin is 2.3.0 b4 which is also a mistake in case you didn't notice it.

Frank wrote: Hi,
Thanks for reporting this issue.

If this is happening to you in version 2.6.0, then its because of a regression introduced by the optimizations made to not localize multiple times when the language changes.
I just uploaded a new beta (2.6.0 b5) that corrects the issue.

You can also fix the issue by replacing the SetTerm function (file Localize.cs, line 269-277) with this one:

		public void SetTerm (string primary, string secondary=null)
		{
			if (!string.IsNullOrEmpty(primary))
				FinalTerm = Term = primary;
			if (!string.IsNullOrEmpty(secondary))
				FinalSecondaryTerm = SecondaryTerm = secondary;

			OnLocalize (true);   //   this was changed to add the <true>
		}

Hope that helps
Frank

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

More
4 years 2 months ago #897 by Frank
Replied by Frank on topic SetTerm won't update

I was using version 2.6.0 b4, and actually the version displayed in the plugin is 2.3.0 b4


Haha, nice catch!
I was testing that the update notifications could be disabled and forgot to reset the version to the latest!

Thanks!!
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

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

More
4 years 2 months ago #907 by Stiv
Replied by Stiv on topic SetTerm won't update
Hi Frank, I'm also having problems with SetTerm but I'm using the latest 2.6.0 b5 build.

It works most of the time, but doesn't seem to work on my prefabs where I SetTerm before displaying it. I've tried toggling the "Pre-Localize on Awake" option but neither setting helped. Any suggestions? Is there any way to force it to do the translation? Although I guess that's what "OnLocalize (true)" should be doing.

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

More
4 years 2 months ago #915 by Frank
Replied by Frank on topic SetTerm won't update
Hi,
I tried reproducing the issue with instantiating a prefab and calling SetTerm but it is working for me. I tried executing the following code:
			var go = GameObject.Instantiate( prefabText ) as GameObject;
			go.transform.parent = CanvasGO.transform; // only did this because prefabText was an UGUI text

			var loc = go.GetComponent<Localize>();
			loc.SetTerm("Otro");

I tried running that code when I clicked a button, then on the Start() method and finally on the Awake() method of a custom script.
No matter where, it was always working for me.
Just notice that if the prefab have Unity New UI texts, and you execute on the Awake, the text changes, but the RectTransform may collapse if its not set anchored correctly.

Can you tell me what steps I can do to reproduce your issue and if you can show me a section of the instantiation code you are using, I can try reproducing it over here.

Thanks,
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

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

Time to create page: 0.191 seconds
Template by JoomlaShine