Implement smart text wrap for translations

More
4 years 1 month ago #1060 by hunleyexpress
The Unity text best fit does not work intuitively (or correctly) since you cannot clamp the horizontal to a max width or a maximum number of lines. So, If I have set my english text to best fit with a max of 30 it looks good. But, when I add the German translation it seems to do best fit on the english *before* the translation so my German either overflows or wraps, depending on the setting. It would be nice if the I2 plugin would re-calc the best fit size *after* the translated text is in place. Currently I have to make all the languages smaller to accommodate the longest language.

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

More
4 years 1 month ago #1066 by Frank
Hi,
I may not be following you correctly. I agree with you that the bestfit option of the Unity UI Text missbehaves and it breaks from time to time, more so if combined with different horizontal/vertical alignments.
However, I was doing some test in the example UI scene and the plugin seemed to be behaving correctly.

What I did was:
1- Opened the uGUI Localization Example scene.
2- for the "Basic Text" term I left the english translation as it was, Added 4 more lines to the spanish translation and made the french, only 5 characters long.
3- Selected the Text object that has the Basic Text assigned and enabled BestFit, also set the overflows to Wrap and Truncate.

If I execute the scene after that and change between the languages, I always get the text inside the text boundaries. The English is fine, the Spanish (as it is 5 lines) becomes small, and the french grew accordingly.

I may be missing some step, as I'm not able to get the issue where the bestfit is not recomputed for the new text.

Can you please, describe what steps should I follow, or setup the uGUI Localization scene to reproduce the issue and email it to me?
I'm about to release a new update and will like to include a fix for this issue so you could move forward without having to do a workaround.

Thanks a lot,
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 1 month ago #1068 by hunleyexpress
Hi Frank, the problem I ran into is more when you need to keep things constrained. And I am perfectly willing to believe that I just did something wrong and fixed it by hitting it with a hammer, so to speak.

So, make a square button (mine is 128x128) with the word 'SAVE' centered in X and Y on it. Set to best fit and a range. I'm using the "URW++ - Eurostyle-Reg2" font, so 5-28 with a default text size of 14 were my params. SAVE filled the button nicely without going over. Set the German translation to 'SPEICHERN'. For me it did mid-word wrapping and put it onto two lines or overflow made it go wider than the button. What I want is to keep it on 1 line and not word wrap, but shrink it instead within my limits. It should only do mid-word wrapping if the smallest size I set can't fit. My fix is to clamp the maximum so German fits (5-24, instead of 5-28). It works, but English is smaller than it needs to be and doesn't look as nice. I haven't proven, but it looks like the word wrap determination is done based on fitting english or some other order of operations issue.

Does that make more sense? Am I just doing something wrong?

BTW: I am still using the 2.5.0f1 on Unity 4.6.8f1 because we have a release going out the door. One of the plugins failed on Unity 5.2.1f1. We will be upgrading both as soon as this is out the door.

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

Time to create page: 0.156 seconds
Template by JoomlaShine