Character Limits

More
7 years 7 months ago #1745 by AMobileDeveloper
Howdy; it's feature request time!
At the company I work for, we've integrated I2 into our project and have been really happy with it so far. That said, there's a feature that would be very useful for folks like us: character limits. Currently, we have it set up so that larger texts get shrunk down to fit the space provided; however, you can only shrink text so far before it starts looking bad. We're targeting a lot of markets, and so are outsourcing our translation work to various localization companies around the world, and we want to be able to tell them the character limits for the translation for each term. Currently, we have to do this by hand; someone has to look at the localization term by term, figure out limits, and enter them in the database where our translators work and can see them.

We'd love the following feature(s):
-The ability to enter a character limit for the translations for a given term (thus, our UI Designer could enter them while setting up the objects, knowing what would look good).
-Have that character limit be enforced when localizing at run time (maybe make this optional; I could see folks preferring both enforcement and non-enforcement)
-Make the character limit be saved out into its own column when exporting Localization data to csv (so we can easily pass it long with the terms to our translators)

I don't what kind of continued development you're doing on I2, but I can see a lot of folks who plan to localize to many regions really liking this feature.
In any case, we've been happy with I2 so far, and will continue to use it regardless. Thank you for producing and supporting such a good product.

Cheers,
Jonathan

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

More
7 years 7 months ago - 7 years 7 months ago #1746 by Frank
Replied by Frank on topic Character Limits
Hi,
Sorry for the delay in answering back, It has been crazy these days and I wanted to give this proper thought as it looks like an interesting idea.

Initially I thought in reusing a maxCharactersPerLine variable that its already been used to cap the Right-To-Left languages, even more given that the same term could be used in different labels, where each of them could have a different with, so a single number will not cut that case.

I also thought in adding a new modifier (aside the ToLower, ToUpper, TitleCase, etc), make one MaxLength. But again, even thought it solves the issue of capping, there is no way to reporting that in the Spreadsheet given that this information is in the Localize component, not the LanguageSource. And the same term could be used in different screens/scenes in labels with different width.

Ultimately, I think the best is to use the built-in description and callback functionality:

The ability to enter a character limit for the translations for a given term (thus, our UI Designer could enter them while setting up the objects, knowing what would look good).
Make the character limit be saved out into its own column when exporting Localization data to csv (so we can easily pass it long with the terms to our translators)


If UI designers want to tell the translators the maximum size, they can add a description to the Term in Unity, that will show as a note in the Spreadsheet and as a separate column in the CSV files. Translators could then use that as a guideline.




Is even possible to define custom lengths per language in case the languages use different fonts. so, "MaxLength" could be the default, and then MaxLength(lanCode) is for any language that will override that value.



Have that character limit be enforced when localizing at run time (maybe make this optional; I could see folks preferring both enforcement and non-enforcement)


You can use a script similar to the following one for any text that should be capped.
Basicaly, it just registers itself as a callback, and whenever the text is localized, it checks the description for the MaxLength and caps the translation.
namespace I2.Loc
{
    [RequireComponent(typeof(Localize))]
    public class LocalizationCallback_CapText : MonoBehaviour
    {
        void OnEnable()
        {
            // Register itself as a callback
            var loc = GetComponent<Localize>();
            loc.LocalizeCallBack.Target = this;
            loc.LocalizeCallBack.MethodName = "OnModifyLocalization";
        }

        public void OnModifyLocalization()
        {
            if (string.IsNullOrEmpty(Localize.MainTranslation))
                return;

            // Get the description of the current localized Term
            var termData = LocalizationManager.GetTermData( Localize.CallBackTerm);
            if (string.IsNullOrEmpty(termData.Description))
                return;

            // Check it has a MaxLength tag
           int idx = termData.Description.IndexOf("MaxLength:");
            if (idx < 0) return;

            // extract the length (could be using regex but this should be faster)
            int idx1 = idx;
            while (termData.Description.length>idx1 && char.IsDigit(termData.Description[idx1])) 
                        idx1++;
            int maxLength;
            if (!int.TryParse(termData.Description.Substring(idx, idx1-idx), out maxLength))
                return;

            if (Localize.MainTranslation.Length>maxLength)
                Localize.MainTranslation = Localize.MainTranslation.Substring(0, maxLength);
        }
    }
}

Just attach that script to any Text where you want to enforce the MaxLength, and if the UI artist added the MaxLength tag to the description, then the cap will be enforced

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
Attachments:
Last edit: 7 years 7 months ago by Frank.

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

More
7 years 7 months ago #1761 by AMobileDeveloper
Replied by AMobileDeveloper on topic Character Limits
Sorry for my own delay in responding; I was on vacation and was delightfully far from anything that could possibly give me internet access.

Thank you for responding so thoughtfully. I see why native support for character limits as I suggested might not be quite ideal. Using the description would be a good way to pass that info along to translators, but alas that info is not natively imported by the translation service that we are using; that said, that issue is on their end, not yours, so maybe I'll go pester them about it :)
That's a handy script for enforcing character limits; I will definitely reference it should be decide to pursue hard limits like that.

Thank you again for I2 and your active support of it. I'll be sure to add my positive review to the others once we go live.

Cheers,
Jonathan

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

Time to create page: 0.295 seconds
Template by JoomlaShine