Search Unity

I2 Localization ( The most complete Localization solution for Unity )

Discussion in 'Assets and Asset Store' started by Inter-Illusion, Feb 27, 2014.

  1. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    Last edited: Feb 24, 2019
  2. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,

    I2 Localization stores all texts in regular strings, and saves them inside unity asset or gameobjects. That way, by itself, the plugin doesn't impose any text size limit, but I'm not aware if Unity serialization has any limit or if Google Spreadsheets have a max cell size (if you are using Google Spreadsheets).
    My understanding was that there isn't any limit, but now that you point that out, I will investigate and let you know.

    Said that, even if there is a way to bypass that limit, my advice is not to store those big texts inside the LanguagesSource as that will be in-memory at all time.
    Instead, my advice is to set it up this way:

    1- Create a term for your legal data: e.g. TERM_PRIVACY (English: "PrivacyPolicy_en", Spanish: "PrivacyPolicy_es", etc)
    2- In a resources folder, place txt files with those names e.g. PrivacyPolicy_en.txt, PrivacyPolicy_es.txt
    3- Add a Localize component to the label where you want to show the policy and select the term.
    4- Set a callback (http://inter-illusion.com/assets/I2LocalizationManual/Callbacks.html) with the following script:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. namespace I2.Loc
    5. {
    6.     public class Callback_LoadTXT : MonoBehaviour
    7.     {
    8.         public void OnModifyLocalization()
    9.         {
    10.             if (string.IsNullOrEmpty(Localize.MainTranslation))
    11.                 return;
    12.            
    13.             TextAsset asset = Resources.Load<TextAsset>(Localize.MainTranslation);
    14.             if (asset==null)
    15.                 return;
    16.            
    17.             Localize.MainTranslation = asset.text;
    18.         }
    19.     }
    20. }
    21.  

    That way, the big Privacy texts will not be loaded to memory until the moment you need to show it. At which point, the Localize component will get the translation to the current language (which will be "PrivacyPolicy_en" or "PrivacyPolicy_es").
    Then, the callback will be executed with that translation, and it will load the resources file with that name, and show its text.

    Yes, you if specify the name of the font in the Secondary Tab, it will load the font with its default material.
    If you set the name of the material, it will use that material with the font that corresponds to that material.
    If you want to select a custom material with a different font. Do: "[MaterialName]FontName" That will load the font and the material and use those.

    Hope that helps,
    Frank
     
    JohnnyFactor likes this.
  3. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    Thank you, that worked great. I put in the callback and it's correctly calling the txt files. I do wonder though-- how does it know the file extension is ".txt"? That's not specified anywhere in the script or the term.
     
  4. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Unity uses the file extension to know what type of Asset it is (e.g txt becomes a TextAsset, png becomes a Texture asset, etc).
    When accessing an asset using Resources.Load, only the fileName is needed (relative to the Resources folder). And given that the scripts is doing Resources.Load<TextAsset>(filename), its requesting a txt (json or other similar text file) located at that filename.

    Here is a bit more info: https://docs.unity3d.com/ScriptReference/Resources.Load.html

    Hope that helps,
    Frank
     
  5. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    On Android sometimes it uses one string for all records
     
  6. romit99

    romit99

    Joined:
    Feb 8, 2014
    Posts:
    10
    Hello, we are having issues with Arabic. The multi line Arabic text is showing wrong text alignment after localization.
    It should crop extra text and write in the line below but it's writing in the line above. Could you please help us out with this issue? does the plugin not support Arabic anymore? We also bought another plugin https://assetstore.unity.com/packages/tools/localization/56625 but then it conflicts with yours and we already have used several translations with your plugin. Please help me out! Thank you!
     
  7. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,

    Can you send me a bit more info about your setup.
    - Can you verify that all the records get different Term names.
    - Are you using a single LanguageSource (I2Languages.asset) or do you have several sources in your scenes?
    - If you switch languages, does the records get different translations or do they always keep the russian one?
    - How are you setting the term (are you calling SetTerm at runtime or are those records always there with the term assigned)?

    I have been double checking the test examples I have here, and the wrapping seems to be working as expected for me.
    Can you please post or email me the arabic text you are using, and a screenshot of how it looks for you.
    I can try using that same text and see if it missbehaves for me.
     
    romit99 likes this.
  8. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi! This behaviour happens from time to time and only on real device. And most of time everything is fine. I have single LanguageSource. I am using LocalizationManager.GetTranslation method.
     
  9. romit99

    romit99

    Joined:
    Feb 8, 2014
    Posts:
    10
    Thank you so much, I have sent you the message in person along with links to images.
     
  10. maxi_sn

    maxi_sn

    Joined:
    Oct 18, 2018
    Posts:
    6
    This bug is still present in the current version
     
  11. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Thanks for remind me about this, I totally forgot to submit that change.
    I just merged it, so it will be in the next release.
    Again, Thanks for reporting this!
    Frank
     
    Last edited: Mar 7, 2019
  12. jmdeb

    jmdeb

    Joined:
    Jul 28, 2017
    Posts:
    23
    Is there by chance a way to use a localized term...in the 'Prefix' and 'Suffix' field ?
    I have the term 'Light'...and would be able to add 'Front' or 'Back' or 'Side'...for suffix! (those terms being themselves localized of course!)
    ...or am I forced to create as many terms as 'Back Light', 'Front Light', 'Side Light',..?
    Thanks!!
     
  13. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi there! Button translate on the Languages tabs doens't work if a lot of strings needs to be traslated.
     
  14. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    I'm currently testing a fix for that, hopefully, it will be included in the next beta.
    One thing to try in the meantime:
    Sometimes, after the translate all fails, you can try clicking it again until it finishes translating all terms. Every time you press the button, a batch of terms are translated correctly, but the free tier of Google Translate complains about too many translation requests in a short time, so the rest of the terms fail. If you wait a few seconds and click it again, another batch is translated, and so on.

    Sorry about that inconvenience and hopefully this new fix will correct it. I'm trying now with different terms amounts and timings.

    Prefix and Suffix where not designed to be localized. They are mainly for things like adding ":" or "." after translations.
    But if you need to add a localized text before or after a translation, you can either use callbacks (which allows you to modify the translation in any way you need, and even request new localizations)
    http://inter-illusion.com/assets/I2LocalizationManual/Callbacks.html

    or use parameters (translation can be "{[PREFIX]} My text {[SUFFIX]}"
    http://inter-illusion.com/assets/I2LocalizationManual/Parameters.html
     
  15. lcmin45

    lcmin45

    Joined:
    Feb 21, 2019
    Posts:
    3
    hi,

    I have a question.
    I think this asset seems to use the Google translation API.
    If this asset use the Google Translate API, do I need to purchase the Google Translate API when I create a translation chat system?
    Or do you not have to pay extra for translation by purchasing this asset?
     
  16. Adrien-Ninpo

    Adrien-Ninpo

    Joined:
    Oct 2, 2018
    Posts:
    17
    Hi,

    I'm trying to localize a TextAsset object instead of a string, but `GetTranslatedObject` always returns null.
    I am about certain I configured my language source properly, the method I use otherwise works fine with localized string.
    What did I get wrong ?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. using I2.Loc;
    6.  
    7. public class TranslatedScript : MonoBehaviour
    8. {
    9.     [TermsPopup] public string stringTerm;
    10.     [TermsPopup] public string assetTerm;
    11.  
    12.     public string outputString;
    13.     public TextAsset outputAsset;
    14.  
    15.     void Awake(){
    16.         outputString = LocalizationManager.GetTranslation(stringTerm); // ok
    17.         outputAsset = LocalizationManager.GetTranslatedObject<TextAsset>(assetTerm); // null
    18.     }
    19. }

    (The objects look like `*.srt` from there, but I actually renamed them to `*.srt.txt`, so Unity does know they are TextAssets)
     

    Attached Files:

  17. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    I have never tried to localize a text asset before, will try it as soon as I get back to double check that all works as expected.

    But my guess is that your issue comes from having the file extension in the translation.
    If you change "subs_urbex.srt" by "subs_urbex" it should work as expected.
    http://inter-illusion.com/assets/I2LocalizationManual/AssetsTab.html

    If it doesn't, please verify that the file is referenced correctly in the Assets tab or in the Localize's Referenced Assets section.
    The issue with the extesion, is that the plugin tries finding the asset by doing the following:
    1- It searches for an asset with that name in the Assets tab and in the Referenced Assets section. (it compares by name, so no need to use the extension)
    2- if coudn't find it, then it tries loading it from the Resources folder. Resources.Load(xxx) doesn't need the extension either.
    3- if still can't find it, then it checks if you have any AssetBundlesManager, and tries loading from there.

    Hope that helps,
    Frank

    BTW, THANKS A LOT for uploading a package with the setup that gives you issue so that I could try it. As soon as I get back I will check it out, and it will HELP ME A LOT to find if there is any problem there!!!
     
  18. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    The plugin doesn't use the Google Translate API. It uses the free tier which allows you do the translations without paying. For that it uses the WebService, which works similar to writing the text in an Spreadsheet and using the "=GOOGLETRANSLATE(xxx)" formulae.
    The limitation is that all your calls should only last for a total of 90 minutes per day. But given that requesting a translation (even when Unity takes some time to upload and download the request), in the Google side, it is processed in fractions of a second, so you can do LOT of translations requests per days.

    Hope that helps,
    Frank
     
  19. Adrien-Ninpo

    Adrien-Ninpo

    Joined:
    Oct 2, 2018
    Posts:
    17
    Removing the `.srt` from the filename didn't solve the issue for me. The assets are well referenced under the Asset tab of the Language Source.
    I didn't use use any sort of Localize script on this at first. I'm not sure how I should have plugged both scripts together aside from triggering my script via the `On Localize Callback` Event. I tried using one anyway, made sure the right term and references were set, but still no changes.

    In the meantime I also tried localizing other assets, Textures and Sprites, with the same method; in both cases by setting terms as "Object" and "Texture" or "Sprite". I also tried recovering everything with
    GetTranslatedObject<UnityEngine.Object>
    in case some casting was causing the issue.

    In the end I've never been able to get anything but null out of this method.

    All the extensive tests I made were on Unity 2018.3.0f2. Though the issue I had with text assets to begin wa first found on 2018.3.6f1.

    Edit: Placing asset in the Resources folder did not yield any result either.
     
    Last edited: Mar 19, 2019
  20. Adrien-Ninpo

    Adrien-Ninpo

    Joined:
    Oct 2, 2018
    Posts:
    17
    I finally figured a way to not get null out of
    GetTranslatedObject<T>(string term)
    . It seems this method is searching assets by asset name and not by term name like the prototype implies.

    This can't be the intended behaviour, is it?

    This is just like using
    Resources.Load
    , but without the resources folder. I don't need I2 to achieve that result, and it's not helping with localization; if I knew the name of the file I wanted already, I wouldn't need I2 to tell me what file to use.
     
  21. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Ohh, Now I see where the confussion is.
    GetTranslatedObject is not meant to get the object from the term, it is just meant as a way to get a object by name from the Assets tab or Referrenced Assets folder.

    That function is used internally in the Localize component after the term is translated to find which asset should be used based on the current language.

    The correct approach to get the asset corresponding to the current language is like this:
    Code (csharp):
    1.  
    2. string translation = LocalizationManager.GetTranslation("My Term");
    3. TextAsset asset = LocalizationManager.GetTranslatedObject<TextAsset>(translation);
    4.  
    Said that, I see this can lead to confusion and that it can be useful to get the translated object directly from the term name. So, I'm going to add a function for that in the next release.

    Hope that helps,
    Frank
     
    Adrien-Ninpo likes this.
  22. mathias_unity633

    mathias_unity633

    Joined:
    Jul 17, 2018
    Posts:
    35
    Hey! I really love this localization framework, by far the best one I have ever used!
    One question: Is it possible to add sprites to a google docs sheet? You can insert images into cells but I2 seems to parse it as text, and it becomes an empty string. Is there a way around this? I like to use 'replace' when downloading sheets so I don't like putting in sprites manually every time.
    Cheers. If this isn't possible yet, I would really really love this feature!
     
  23. Adrien-Ninpo

    Adrien-Ninpo

    Joined:
    Oct 2, 2018
    Posts:
    17
    Thanks for the clarification !
    I would never have figured that `GetTranslation` would return the asset name for non-string terms. -I didn't even expect it would work or return anything at all.-

    Everything works fine now, it also works with the double *.srt.txt extension
     
  24. Deleted User

    Deleted User

    Guest

    Hi, great asset so far, thanks! Don't know if you've heard about it, but deepl (.com) is way better than google translate, could you add support for this?
     
  25. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    Thanks for the suggestion, I was not aware of deepl but it looks interesting and the translations I tried looked very good.
    Will try adding support for it as an anternative to Google Translate.
     
  26. cmos

    cmos

    Joined:
    Aug 6, 2012
    Posts:
    10
    I am having issues with adding Chinese, it just doesn't show up on webgl.
    Its fine in unity editor, but its just blank when switching from English to Chinese.

    I tried registering to your forums to ask and it doesn't let me.
     
  27. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    Rendering of the characters is performed by Unity UI, TextMeshPro, etc (depending on what you are using).
    The problem you are describing is most likely happening because I2 Localization is setting the correct Chinese text, but the font you are using doesn't support them in that platform.

    If you are using the Unity Default arial font, in the editor and some platforms they use a version that contains lots of characters, but in WebGL, it gets replaced by a simpler arial that has far fewer character sets.

    If that's your case, my advice is to download the free Arial Unicode ttf and use that one instead of the default unity one.
    The Arial Unicode is a special version that contains the full Unicode character set, so it will render any language in all platforms.

    Hope that helps,
    Frank
     
  28. lucus

    lucus

    Joined:
    Dec 11, 2012
    Posts:
    1
    Hi

    I am working on a bigger project with lots of dynamically downloaded assetbundles each being created and updated seperately from our main app. An assetbundle can have several translations to different languages. these translations are outsourced. We are considering using i2loc (which we already have a license for) but I am not very familiar with i2-localization and have a few concerns and questions. Having control of our pipeline is very important to us, but we don't want to reinvent the wheel.

    1. Our app can cache its assetbundles and play in offline mode. I was wondering what sort of offline capabilities i2l has. Is it pollible to preload translations used by assetbundles and use them offline later (without having to load the assetbundles)

    2. We want to use the google sheet feature or otherwise somehow avoid rebuilding assetbundles when translations are added or updated.
    if we have hundreds of assetbundles and potentially many thousand users, will the google sheets integration hold up= Or will googly throttle the app's requests?

    3. We want to have the app UI in one language (e.g. the system language) but the loaded content from assetbundles must be able to be in a separate language at the same time. Does the plugin allow for multiple languages being displayed simultaneously without complications?

    4. We have "development" and "productions" versions of our assetbundles, so the production team can test their content in-app before the assets are copied over to the production server. How does the plugin fare with multiple versions of the same content, even when using google sheets? We want to "lock" the production content so their translations do not suddenly change, but be able to iterate on the "development" content.

    Thank you!
     
  29. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    Sorry for the late reply, I have been on vacation out of the country for the last couple weeks and I just got back.

    I2 Localization main strength is that it provides lots of editor and previews to interact with the translation and languages. But the very core, it is still a kind of dictionary where a value is mapped to other values based on the current language. This mapping data is stored in the LanguageSource. And you have full access to those sources, so you can customize it and manage it in a way that matches more closely your app design while still using the editors and synchronization features.

    There are several ways to handle this situation.
    I2 Localization has the concept of "Global" Source that are accessible everywhere in your app (e.g. I2Languages.asset). But there is also "Local" sources, that are mostly added to specific scenes and are only loaded/usable while that scene is active.
    When working with extandable content through AssetBundles, most users, just use local sources that are added to those AssetBundles. (either as an asset or as a GameObject inside one of the scenes in that bundle). That way, they are only downloaded when needed and used when the AssetBundle is used. And you can still use the caching you use for your bundles.

    Another way, is to save the localization data into a CSV file and add that file to the bundle. Then, when you need it, call the source.ImportCSV function to load the CSV into the global source.
    http://inter-illusion.com/assets/I2LocalizationManual/ImportingaCSVfile.html

    If you use a local language Source inside the bundles, they can keep their link to the Google Spreadsheet and if the spreadsheet is changed, they will get updated.

    There is a limit to what google scripts allow in their free tier. But that limit allows you to easily handle thousands of players.
    The limit is that the WebService can only be ran for 90min a day. Given that each time I2Localization downloads data from google, the downloading can take some time, but the actual script execution time is around a few milliseconds, then lots of players can be updated each day.
    Nonetheless, if your app gets to a player count that it reaches the limit, those players are rescheduled for the next time, they run until they get updated.

    Also, notice that normally the plugin just does a quick pick to see if the spreadsheet has changed (it compares the modified date with the one it has downloaded previously) and only if thats different, then it does the bigger downloading. That way, its fine for even more players to be checking for modifications.

    If you have lots and lots of daily players, then if the limit is reached, what will happen is that the first day lots of them will get updated, then the next day will update another batch, etc, until all of them are updated.

    Another tool to help decreasing the Google load is to set the Update Frequency to Weekly or so instead of Daily. That way, players only check for modifications weekly, but if there is a modification and the google limit is reached, then they try downloading every time the game starts until they get updated.

    Multiple languages active at the same time are not directly supported.
    But you can easily use callbacks to allow that.
    Here is a script showing how to implement an AlternativeTranslation.
    http://inter-illusion.com/forum/i2-localization/209-multiple-languages-at-the-same-time#841

    I have had a feature like that in my todo list for a while now, but it seems there is always something with more priority to do :-(

    Basically, it is recommended, that everytime you release a build, you switch to a new spreadsheet. That way, old builds can access the old spreadsheets without having the risk of translator removing terms that were needed previously but not longer used.

    In that way, old spreadsheets should be updated to fix typos, change weekly messages or things like that. But any new localization should be done in the spreadsheet corresponding to the new release.

    Hope that helps,
    Frank
     
  30. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Would be great if you could clean up the editor UI and make it look like it actually belongs in the Unity inspector. Not sure how it performs and looks under the Unity Pro skin but it is really not nice to work with in the light skin.

    Look for example at how Unity cleaned up a really bad Inspector design of TextMesh Pro after they took over on developing that.

    You can start with simple things like not forcing the background colour to some dark gray so we now have black text on dark grey back.

    Part of developing editor tools is making a good experience for the user of the tool and this asset is mature enough, and I am sure popular enough, that I would expect some more thought going into what the inspectors look like.

    There are also still the occasional error related to GUI Layout Begin and Ends.Sorry, can not post example right now but know I've seen them come up just last week.

    - Why do you force the dark grey background? Use the Unity skin's active theme.
    - Those parse, categorize, etc tabs under Tools do not even look like tabs or buttons.
    - If you do not drag the inspector wide enough then some parts of the UI is hidden (you need to look into wrapping or a better layout that fits into a more narrow inspector)
    - Why is the CharSet tool's list so long? The rest of UI that follows below is pushed so far down that you need to scroll to get to them in Inspector.
    - There are many more things I could point out but I think you get the idea.

    Some shots to show what I mean.

    04.png 05.png
     
  31. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    You are totally right, the inspector needs a polish pass.
    The different coloring and some of the layout are from the times of Unity 4.x where the darker color was needed to better separate the editable part from the layout when in the Dark interface.
    However, there has been changes to clean that a bit, but the color has remained the same.

    In my todo for one of the next releases, I have a task to improve the interface a clean it more when possible. There are a few pages where the lists go to a wrong length (specially in retina displays). Also, I want to consolidate the action buttons, because over time I have added more and more small features that have been clutering the inspector. Now is the time to clean it and group them in the correct space.

    I'm targeting to start focusing in that during the next updates.
    Hope that helps,
    Frank
     
    Leslie-Young likes this.
  32. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hello, I have bought it, and have started learning how to use it, have seen the videos and read most of the online documentation, but there is something that I still do not understand, and it is that what I really want is that the translation is made directly corresponding to the device language configuration WITHOUT the player or device user having to change the language manually using any buttons.

    FOR EXAMPLE I mean that if the device is in English then i2 Localize script should show the texts in English, and if the Device is in Spanish, then i2 Localize script should show the texts in Spanish, WITHOUT the player or device user need to choose any language and do not hit any button to change language

    I DO NOT want to put any kind of flags menu buttons to be able to change the language as shown on the second tutorial video, this should be done directly according to the device configuration instead.

    Please can you be so kind to tell if this is how it works by default, or if there is any special instructions or tips for this to happen, or is anything additional that may be needed to do it?

    thanks very much for any possible help

    Waiting for your answer I send you my best wishes
     
  33. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    Thats how it works by default.

    This explains it in more detail:
    http://inter-illusion.com/assets/I2LocalizationManual/InitialLanguage.html

    But basically, once the game starts for the first time, it checks the device language and uses the closest language you have in I2 Localization, or fallback to the first language in the Language's list.

    Hope that helps,
    Frank
     
    SpaceRay likes this.
  34. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks very much for your very fast help and for the good news that this is done by default and so I suposse and think that you do not need to add any additional code or scripting to any part of my game, just the LocalizationSource on Hierarchy and the Localize script on each object to be translated
     
  35. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    PLEASE, HOW IS DONE THE TRANSLATION FROM A SCRIPT BASED OBJECT?

    I have already done the translatation of all the simple text objects and it works right, BUT now I need to translate some texts that are depending of some scripts and do not know how to do it

    For example I have this on Inspector NewsTicker_script_translate.jpg

    So, for this you can´t add a Localize script as it will not recognize it as text because is a script based text, So please how would I be able to localize this 8 elements shown?
    The texts are NOT inside the script, just on Inspector.
    ---------------------------------------------------
    Additionally I have also another script that is a weapon selector where the names are taken from a list in inspector from another script, and also another one that the text is from the script.

    so I wonder how works the I2 Localization with scripts and how is done when the texts to be translated are not directly in inspector, or not on a Unity text component, and are from scripts based objects to be able to localize them?

    I have to say that I have really very little scripting knowdlege, so it is not at all easy to modify any script

    Thanks very much for any possible help
     
    Last edited: May 3, 2019
  36. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Please, for the above post I have sent you the purchase proof by PM on private

    thanks very much

    best wishes
     
  37. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Hi,
    If I understood you correctly, in one of your scripts you have something like:
    Code (csharp):
    1.  
    2. public class NewTicker
    3. {
    4.       public string[] NewItems;
    5.       public string OtherStringValue;
    6. }
    7.  
    And you want to get those string localized to the current language.

    For this, the plugin has a LocalizedString that works as a replacement of the C# string.
    http://inter-illusion.com/assets/I2LocalizationManual/LocalizedStrings.html

    When setting the LocalizedString the value you set is the term name, but when getting its value back it will return the translation to the current language.
    Code (csharp):
    1.  
    2. // If "Term1" is in your I2Languages.asset and has "Hello" as its English translation, then:
    3. LocalizedString locString;
    4.  
    5. locString = "Term1";
    6. Debug.Log(locString);  // Prints "Hello" to the console
    7.  
    Also, the inspector will show a popup for selecting the term.

    That way, you just need to:
    1- Change the "string" by "LocalizedString" in your scripts.
    2- Create a Term in the I2Languages.asset for each of those values and add a translation to each language.
    3- In the inspector of your script (or from code) change the text of the string to be those terms you just created

    Hope that helps,
    Frank
     
    SpaceRay likes this.
  38. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks very much for the detailed explanation and I understand it, but the problem is that the script does NOT use any string, I have sent you a private message with the full script for you to see and and as said there, I can pay you if needed for your help
     
  39. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi @Inter-Illusion
    I'm trying to localize an app in Arabic - to do so I did the following step:
    • Added a the Arabic language
    • Added an Arabic font
    • Added a "font" term that localizes different TMP assets for each language
    • Added the Localize script on all GO that contains a TMP Text and add the "font" term in the secondary tab
    Doing all that seems to work and I was gladly surprised to notice that when switching to Arabic all TMP text scripts have their "RTL" option checked.

    But I'm facing one annoying bug/behavior, when switching back to English for exemple, using code in some Awake method, the RTL option remains checked for all TMP text script that are on dynamically instantiated prefabs. I tried to force the Localize script to call OnLocalize(true) after the prefab is instantiated but it did not work.

    It's like when an RTL language is set the RTL option is automatically checked, whether the TMP Text is on scene object or a dynamically instantiated prefab but when switching back to an not RTL language do not unchecked the option for the later case.

    Am'I missing something ?

    Thanks
     
  40. Anemor2000

    Anemor2000

    Joined:
    Jun 12, 2015
    Posts:
    39
    Hello, since we updated to Unity 2019.1.1f1 (update from 2019.1.0) we have a new bug with I2localization.
    When changing the language, a carriage return (\r) is appended to every term we get via
    LocalizationManager.GetTranslation("the_term");

    This is breaking our game in various ways. Is this a known issue?

    Thank you
     
  41. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Not at all. Thanks for reporting it, I will look at it ASAP.
    Just to confirm, are you using the latest I2 Localization? (v2.8.12f1) I remember there was an issue when importng from Spreadsheets in an older version that caused issues with new lines, but that was fixed in one of the latest releases.

    I will try reproducing that issue and get back to you!

    When switching to an Arabic language, the plugin doesn't change the RTL property in TMPro. Instead it modifies the text so that it renders correctly.
    But it could be happening that TMP detects that its an arabic font and enables that.
    As soon as I get back I will check why exactly that its happening and let you know how to fix it.

    Hope that helps,
    Frank
     
  42. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Thanks, I really can use a little help on this one :)
     
  43. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    Hi there! Is it possible to use asset without TMP ?
     
  44. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
  45. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    Hello! I have a couple of questions...
    1. How can I detect when no translation is available in the current language? For example, the user has set their language to French, and I have text for English but not for French. "LocalizationManager.GetTranslation" returns the English string if there is no French translation, but I want to detect this case and provide my own behaviour to avoid displaying the wrong language.
    2. Automatic detection of the system language does not work for me. Any idea why? I've tried setting my Windows 10 system settings to German and deleting my player prefs, but when I start the game it still uses English.
    Thanks in advance!
     
  46. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    In the Languages Tab of the I2Languages.asset there is a setting to show what should happen when a translation is requested but there is translation set for the current language.



    By default, its set to Fallback, which means that if the translation to the current language is not found, then the plugin fallback to the first translation in the Language's list (e.g. German is not found, then the plugin returns the English translation)

    Independently of that, you can find using code if the term doesn't exist by using
    Code (csharp):
    1.  
    2. TermData term = LocalizationManager.GetTermData( termName );
    3. if (term==null)
    4. {
    5.   // There is no term named termName
    6. }
    7.  
    If you also want to check if the term exist but is not translated to the current language:
    Code (csharp):
    1.  
    2. string translation;
    3. bool termExists = LocalizationManager.TryGetTranslation(termName, out translation );
    4. if (!termExists || translation==null)
    5. {
    6.   // There is no term named termName or there is no translation to the current language
    7. }
    8.  
    Thats strange, I just did a quick test, and it loaded the correct language.
    Will do a few more test to see if I can reproduce your issue and get back to you.

    Hope that helps,
    Frank
     
  47. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    Awesome, thank you! Changing Fallback to Empty did the job, and the code I had in place started detecting the empty string as I'd expected it to do originally. I must have just missed that option, apologies.

    Thanks for looking into the default language. Let me know if you need any more information to reproduce, or I can send you a build of my game if that helps.
     
  48. justinpatterson

    justinpatterson

    Joined:
    Aug 14, 2012
    Posts:
    4
    Hi gang, I've been having a bit of an issue regarding Localization in a large project. Frank and I have chatted a bit over other channels, but I figured I'd move the conversation into here in case it helps anyone else in the future.

    I've inherited quite a large code base and the localization works in Editor, but not in builds. I've added some debug logs in the Localize.cs script to try and catch the reason.

    Some initial observations that get other potential problems out of the way:
    The editor logs indicate that I2Languages.prefab is properly included in the build.
    Game logs indicate that if I hardcode some localization request, it functions as expected, e.g.:

    I2.Loc.LocalizationManager.Sources[0].TryGetTranslation("CONTENT/CLASS/Defender_Name", out translation);

    will return something like "DEFENDER" depending on the language setting
    Specifically, when running in a build, the Localization tool appears to exit OnLocalize() in the Localize.cs section at the following if statement:
    Code (CSharp):
    1. if (!HasTargetCache() && !FindTarget())
    2.                 return;
    Below is a debug log that I get from a modified Localize.cs - it appropriately fetches the localized text, but then seems to fail at "Target Cache" and "Find Target." Any ideas as to what could be causing it? I should note that UI elements are spawned and destroyed as they are needed. Upon being spawned, they then get set to whatever "Term" they need to be if not already assigned. However, I witness this issue for all elements, both assigned terms when spawned and pre-designated with terms.

    Debug Log:
    TXT_AttackInfo || ...UI/SCREEN/TV_HUD/AttackerTargetsOne || Last Localized Language is: Chinese . Should translate to: "TARGET". Has Target Cache? False, Found Target? False
     
    Last edited: May 26, 2019
  49. justinpatterson

    justinpatterson

    Joined:
    Aug 14, 2012
    Posts:
    4
    Just to update based on discussions with Inter-Illusion / Frank:

    Reviewing those options: I've verified that the correct compile defines are included. Good idea, though! Since I never thought to look at those.

    However, importing a new plugin is a high risk option; after attempting to do an initial import quite a few things broke that seemed unrelated. I can try following the re-import steps again but it doesn't seem like a good option for something with a code base as large as the one I've jumped into. Also, the codebase I'm attempting to build from is a "gold" repo, so it shouldn't have funky mis-versioned plugin issues.

    I'm still hopeful there's something silly I'm missing, or something being overlooked on my part that we can figure out together!

    Any other low hanging fruit I can check out regarding why elements may not find their cached targets?
     
  50. ChristophFandrich

    ChristophFandrich

    Joined:
    Apr 24, 2019
    Posts:
    3
    Hello,
    we have a issue after installing the asset. upload_2019-5-28_8-20-26.png
    Hope you can help us.