Issue with alignment for RTL languages

More
1 year 5 months ago #2853 by Niaobu
Hi,

I found an issue with the "Adjust Alignment" option on I2 Localize components. If the language used when instantiating a component is RTL, but the component was saved in a non-RTL language (or opposite) the alignment gets reversed.

In LocalizeTarget_UnityUI_Text, the DoLocalize function has the following block which runs the first time DoLocalize is called.
	if (mInitializeAlignment)
	{
		mInitializeAlignment = false;
		mAlignmentWasRTL = LocalizationManager.IsRight2Left;
		InitAlignment( mAlignmentWasRTL, mTarget.alignment, out mAlignment_LTR, out mAlignment_RTL );
	}	

This function sets the initial mAlignmentWasRTL to true if the CURRENT language is RTL, not the language used when saving the scene/prefab/component that contains the localize component.

Case where this breaks:

1. Set language to English
2. Create a prefab with a localize component.
2a. Assign a term, select left justification and check the box for Adjust Alignment
3. In the main scene, create a button or something that instantiates the prefab from step 2
4. Set language to Arabic or another RTL language
5. Hit Play
6. The component does not adjust its alignment.
7. (Bonus) If you change the language back to LTR while running, it will change to right alignment.

Our workaround has been changing the order so you assume that all scenes and prefabs were aligned for RTL (initial mAlignmentWasRTL is always false).
This works, but you need to make sure that all scenes and prefabs are always saved from a LTR language.
	if (mInitializeAlignment)
	{
		mInitializeAlignment = false;
		//mAlignmentWasRTL is false initially.
		InitAlignment( mAlignmentWasRTL, mTarget.alignment, out mAlignment_LTR, out mAlignment_RTL );
		mAlignmentWasRTL = LocalizationManager.IsRight2Left;
	}	

From what I can understand, a complete solution would require each component to know if it was saved using LTR or RTL settings, then using that for the initial mAlignmentWasRTL.

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

More
1 year 5 months ago #2856 by Frank
Hi,
You are correct.

Up to the last version of I2 Localization there was no way for the targets to save persistent values, which is needed for this. That's why I changed how the Localize targets work, and in the last release they are able to store any extra data they need. Which allows capturing the RTL flag when the localize component is added, and then keep track of its last value.

In this next release I plan on tackling the issue you are describing, along with removing the MaxCharactersPerLine for RTL wrapping and handling that automatically.

Nonetheless, thanks for reporting this issue, I will add more priority to this task!

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
1 year 5 months ago #2857 by Niaobu
Thanks for the quick reply.

Frank wrote: In this next release I plan on tackling the issue you are describing, along with removing the MaxCharactersPerLine for RTL wrapping and handling that automatically.

This sounds great! Manually determining MaxCharactersPerLine is a pain and does not work well when translating to both arabic and hebrew as they have different numbers of characters for most strings, making it look bad.
Looking forward to the next release!

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

More
1 month 1 week ago #3900 by robal1991
Sorry, for picking up old thread, but I'm having this issue too. Could you tell me in what version was it fixed? I'm currently using a little bit old 2.7.0 because the asset is working great so we haven't really got a need to update :)

The workaround is working for me though, but you have to remember to save scenes with LTR language.

Thanks for help!

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

Time to create page: 0.868 seconds
Template by JoomlaShine