Search Unity

[RELEASED] Smart Localization for Unity3D

Discussion in 'Assets and Asset Store' started by NiklasBorglund, Mar 13, 2013.

  1. gromerr

    gromerr

    Joined:
    May 21, 2014
    Posts:
    15
    wow this works, thanks for help
     
    larku and NiklasBorglund like this.
  2. iqbal_mineral

    iqbal_mineral

    Joined:
    Sep 17, 2014
    Posts:
    3
    I've just stumbled on this last week :)
    (I didn't read this forum last week and sent a bunch of emails, sorry Nik)

    The funny thing is my game text was partially reverted to english if I didn't call that function (some stayed in chosen language)

    Out of curiousity, why I have to set this flag manually?
    Is there any case where user want the game object to re-instantiate on every scene?
     
  3. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hey, sorry about the late answer to your email, been a bit busy lately.

    The original reason why we didn't have the DontDestroyOnLoad() flag in the beginning was that we thought it was a decision best made by the developer. Basically because it's easy to set don't destroy on load, but it's not as easy to revert it - you basically need to destroy the object.
    Frankly, I don't know why someone would want to revert the flag, so maybe @zurric and I will discuss it again :)
     
  4. lemmiwinks

    lemmiwinks

    Joined:
    Nov 19, 2013
    Posts:
    4
    Is there a way to perform a search inside a specific thread in these forums? Because I can't find it...

    Hey thanks again for the awesome localization package, a quick question if I may:
    Is there a built-in way of changing fonts on the fly based on language? I ask because the font we use only supports western languages, and now we're localizing to Russian, so either have to find a font that supports both character sets, or my idea was to change the font at run-time if the language is set to Russian.
    Rolling out a component that does the check would be trivial, but just wanted to make sure it's not already part of Smart Localization.
    Thanks!
     
  5. iqbal_mineral

    iqbal_mineral

    Joined:
    Sep 17, 2014
    Posts:
    3
    I never thought of that but it would be cool to have it on the plugin! :cool:
    (IMHO it's still part of localization-thingy, so yeah it would be cool)

    In my case, I have 3 kind of fonts for latin, russian-specific(sorry I don't know what it's name), and CJK
    Of course I load them once in the beginning and change textmesh font into supported font on the runtime

    Do mind that maybe your game would be seen as a bit lag when you changed the font on runtime (just maybe)
     
  6. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    No, we don't have localized fonts at the moment, but we have it written down in our backlog :) When we add it though, it would probably be added the same way as textures/audio/text assets are right now.
     
    iqbal_mineral likes this.
  7. DiebeImDunkeln

    DiebeImDunkeln

    Joined:
    Nov 17, 2014
    Posts:
    8
    I haven't made text changes for some weeks. Now if I try to open SmartLocalization, I get this error message:

    MissingMethodException: Method not found: 'SmartLocalization.SmartCultureInfoCollection.FindCulture'.
    SmartLocalization.Editor.SmartLocalizationWindow.Initialize ()
    SmartLocalization.Editor.SmartLocalizationWindow.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    I hope you can tell me what's wrong now. I also tried to reimport the package, but without success. Get the same error.

    thanks
    Frank

    Update: found the problem. for some reason I had the editor files more than once in the project.
     
    Last edited: Jul 2, 2015
  8. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Oh, ok. I'm glad that it got solved :D
     
  9. sreveloc

    sreveloc

    Joined:
    May 9, 2013
    Posts:
    2
    The features of this plugin are awesome and really likes me, but..
    What would be the approximation for use with 2D UI features in unity 5?

    I need an advice using this for UI objects (text, images, ...)

    Thanks in advance
     
  10. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    I can't say when we'll support sprites - because it requires a significant system to handle the different atlases - but you can localize textures now.

    For text, we have a helper class that is included in the package in the uGUI folder. Just comment out the defines at the top of the class.
     
  11. StormyShelter

    StormyShelter

    Joined:
    Oct 25, 2014
    Posts:
    7
    Thank you for an awesome asset! (Heja Sverige!)
    When I publish my app on Google Play it says that there are no localizations, even though there are many.
    Is that what "store presence" is in settings?
     
  12. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Haha, yes - Heja Sverige :)

    Yeah, the store presence should fix that. It creates a folder structure within Unity with "res" folders for each language that are used when building for android.

    However, the build fails if a language isn't supported by google - so I used this list to double check with before the folders are created: https://support.google.com/googleplay/android-developer/table/4419860?hl=en
     
  13. StormyShelter

    StormyShelter

    Joined:
    Oct 25, 2014
    Posts:
    7
    Beautiful! Thanks.
     
  14. mr-quoccuong

    mr-quoccuong

    Joined:
    Aug 12, 2013
    Posts:
    5
    Dear Supporter,

    I have already authenticated with Microsoft, But I cannot translate to other languages, there is how only None
    Please help me point what wrong
    smartlocation.png
     
  15. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    You can only translate if the language codes are supported by Microsoft Translator found in this list: https://msdn.microsoft.com/en-us/library/hh456380.aspx

    So to be able to translate you will have to change your "en-US" to "en" since "en-US" is not available in that list.
     
  16. mr-quoccuong

    mr-quoccuong

    Joined:
    Aug 12, 2013
    Posts:
    5
    Thank you, it work
     
  17. RayTsang

    RayTsang

    Joined:
    Dec 14, 2012
    Posts:
    3
    Hi, is it a bug about NGUI Atlas??

    I just create a atlas with 2 images.
    and i drag it in the key "PlayingAtlas"
    a.png

    Then I save it and found it in SmartLocalizationWorkspace\AutoGenerated\en\Prefabs
    It only contain 1 image with the sprite "image834" and the content is "PON" which is the image of "image835"
    b.png
     
  18. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    If you change any of the assets, you'll need to go into the Language(translation view) and press save/rebuild.

    That would be a pretty good feature though. To have in indicator if a localized asset changed or not. I've added it as a feature request on the trello page. https://trello.com/b/asPcg1Tl/smart-localization
     
    RayTsang likes this.
  19. Hokis

    Hokis

    Joined:
    Oct 26, 2012
    Posts:
    5
    Hi Niklas,

    This plugin is amazing, we've managed to put 11 languages in the game without any issues whatsoever. I'd recommend it to anyone who wants to quickly localise a game!

    We've had a small issue with Arabic though, which is when I copy and paste any text strings into the Smart Localisation translate language screen, they automatically flip the wrong way round. Is there any way around this? I've had a poke around the web and it seems to be a common problem with some text editors, but I can't see a solution or any options I can change within Unity or the plugin that will help.

    Cheers,
    Dan
     
  20. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Thanks for the kind words :)

    Yeah, arabic and RTL languages can be a bit of a hassle. Unity as of right now does not contain support RTL or bi-directional text - so that's why it looks odd in the editor text fields.
    And unfortunately Smart Localization does not have any support for it either(yet), so it will look weird at runtime as well.

    The thing with implementing RTL and Bidi is that it's a huge feature that needs to take a lot of different factors into account. Unicode has an algorithm to handle both RTL & LTR in the same string called the Unicode Bidirectional Algorithm.

    Apart from that, with your specific case of arabic you need something called contextual shaping. Characters look different in arabic depending on the location in a word. e.g. Arabic letters have different visual appearance for if it's isolated, at the start of , at the middle and at the end of a word.

    You probably have to do these operations before rendering your text to make it readable. And if you do any word-wrapping in the text, be sure to make it before the contextual shaping if your wrapping is based on whitespaces. This is simply because a whitespace might not be where a word ends after the shaping.

    I've seen some plugins in the asset store that performs this - but I haven't found one yet that does it well and properly. If anyone knows of one - let me know :)

    With that said, we want to solve these kinds of issues, and it requires some planning and extra research to make it good - so to be honest it might take a while.
    We are currently working on to other (quite large) features for Smart Localization that need to be finished first; Multiple language files & google doc-support.

    Hope that helps,
    /Niklas
     
  21. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi @NiklasBorglund ,

    I updated to the last version 2.2.1, and I got a new issue like, I'm changing the language by calling:
    Code (CSharp):
    1. private string defaultLanguage = "en";
    2.  
    3. void Awake(){
    4. private LanguageManager lm;
    5.  
    6. string currentLanguage = PlayerPrefs.GetString("lang");
    7.  
    8.             if (!string.IsNullOrEmpty(currentLanguage))
    9.                 defaultLanguage = currentLanguage;
    10.  
    11. lm.ChangeLanguage(defaultLanguage);
    12. }
    *But when opening another scene the language change back to English, even if I change and save my language in my settings, what can cause this ? Thanks !
     
  22. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Try calling LanguageManager.SetDontDestroyOnLoad (); at the startup of your project. That should solve your issue.
     
    RoyalCoder likes this.
  23. gyrosp

    gyrosp

    Joined:
    Jul 29, 2015
    Posts:
    10
    I tried to show a localized string in the editor in the OnGui-method like this:

    Code (CSharp):
    1. localizedText = SmartLocalization.LanguageManager.Instance.GetTextValue("test");
    Unfortunately I get this error:
    Any idea what the problem might be?
     
    Last edited: Sep 3, 2015
  24. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    The LanguageManager isn't designed to be used in editor scripts. So trying to get a language value in editor from it will probably not work.

    However, we have some editor methods that you can use.

    Use this method to get the dictionary with values from a specific language
    Code (csharp):
    1.  
    2. using SmartLocalization.Editor;
    3.  
    4. void MyMethod()
    5. {
    6.   Dictionary<string, LocalizedObject> values = LanguageHandlerEditor.LoadParsedLanguageFile("en", false);
    7. }
    8.  
    "en" in this case is the language code of the language you want to get the values from.
     
  25. Alessaint

    Alessaint

    Joined:
    Mar 21, 2011
    Posts:
    43
    Hi Niklas!

    Firstly thanks a lot for this great tool!

    I was just wondering (I guess I might be missing something obvious) - is there an easy way how I could get my hands on root language values in runtime? I know that I can get the root values dictionary via some classes that use UnityEditor but that obviously wouldn't work for me...
     
  26. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hmm, that's a tricky one. But I guess it's possible.

    You can try this. But I can't guarantee that things won't change soon that makes this not work anymore.

    Code (csharp):
    1.  
    2. TextAsset languageData = Resources.Load("Language") as TextAsset;
    3. var rootValues = LanguageParser.LoadLanguage(languageData.text);
    4.  
    Another solution that could work is probably that you create a new culture(if you have pro) that you name to "root" or something and you load that just as any language. Given that you've copied the root values to it first ofc.
     
  27. Alessaint

    Alessaint

    Joined:
    Mar 21, 2011
    Posts:
    43
    Yes, I've bought the Pro version (money well spent :)) so that might indeed work. Thanks a lot!
     
    NiklasBorglund likes this.
  28. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    If someone want to use SmartLocalization with TextMeshPro, use this helper script!
    It is similar to "LocalizedText", just attach it to your TextMeshPro object and you are done.
     

    Attached Files:

    NiklasBorglund likes this.
  29. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That's great! :D
    If you want you could put it up on github gist or similar - https://gist.github.com/

    That way it would be easier to share with a link :)
     
  30. gyrosp

    gyrosp

    Joined:
    Jul 29, 2015
    Posts:
    10
    Hi.

    Today I tested a build of my game on my mobile with german as system language.
    But all localizations are in english.

    How can I detect and set the system language of the device as the default localization language?
    I thought that would be a default behaviour of smartlocalization ;).
     
  31. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    To detect and change the language to use the device language - you can use the code that is in the example class LoadAllLanguages.cs in the SmartLocalization package.
    It's basically most of the code that resides in the void Start() method.

    Worth mentioning is that the SystemLanguage detection in unity is somewhat limited since it doesn't support regions, but it should work just fine for languages without a region.
     
  32. Heretsu

    Heretsu

    Joined:
    Sep 13, 2015
    Posts:
    1
    Hey, great assessts, thank you for that :)
    Can you tell me how to save the chosen language so that it will be the same in all scenes if the player select it in the settings?
     
  33. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Feature request please, specifically for UI label text.

    Can there be a way to have a script attached to any label object where the text can change depending on the language selected, and the script has one parameter for the Key. Then if you call a new routine say when the scene loads, it will find all objects which have the script and iterate through them, pulling the text through for the given Key?

    I know I can code this but this would be a useful feature as standard and mean you just drop a script onto an object rather than having to code things more manually to update label text.

    thanks

    Craig
     
  34. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    Hi tapticc, this feature already exists. Use "LocalizedText" (in SmartLocalization/Scripts/uGUI) script, all you have to do is to remove the first and last line of this script (IF...). Then drag this script to your text label, fill in your key, now every time the language is changed (Language Manager) the text label get its string with the given key!
     
    Last edited: Sep 23, 2015
    NiklasBorglund likes this.
  35. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Perfect, thanks for the quick response :)
     
  36. crismote

    crismote

    Joined:
    Sep 24, 2015
    Posts:
    2
    Hi there! Is there anyway to include HTML tags in the localization? The Unity default text field renders the HTML tags properly, but the Smart Localization just reproduces the tags as text. Thanks for your help!
     
  37. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    You can set LanguageManager.SetDontDestroyOnLoad() in the beginning of your app to make the LanguageManager persist between your scenes.
    To make the language change between scenes you could save your language code into PlayerPrefs whenever you change your language and load that saved language at the startup of your game.

    Hope that helps.

    We store the text in RESX/XML, so I don't see why it shouldn't work. But I guess there could be some sort of escape sequencing during xml serialization/deserialization since xml/html have basically the same syntax.

    Can you give me a testing string for us to investigate with?

    Thanks.
     
  38. crismote

    crismote

    Joined:
    Sep 24, 2015
    Posts:
    2
    Its a very basic HTML, thats why I'm puzzled to why its not working properly. Here are some lines:

    Code (csharp):
    1.  
    2. <p><strong><u>CREDITS</u></strong></p>
    3. <p><strong>Walking on words. Mallorca literària </strong>is a brainchild of Carme Castells, developed by Fundació Casa Museu Llorenç Villalonga, Pare Ginard i Blai Bonet (Consell de Mallorca), 2015.</p>
     
  39. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    So sorry for the late reply.

    What type of text are you using? The Text instance in the 4.6+ GUI? That doesn't support regular HTML tags - only a few of them. <b> <i> and <color>

    http://docs.unity3d.com/Manual/StyledText.html
     
  40. iknikitin

    iknikitin

    Joined:
    Sep 5, 2015
    Posts:
    1
    Hi! Great plugin! But I'm having issue with Chinese language. It works perfectly on iOs 9, but doesn't show chinese localizations on iOs 8.3
    Need this fix so bad! Thank you!
     
    Last edited: Oct 20, 2015
  41. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi,

    I'm sure we can solve it :)

    Can you give us some more information about what Unity3d version & Smart Localization version you are using? And what's the language code of the language that doesn't work?

    Also, what is happening in your iOS 8.3 version? Do you see any language values?
     
  42. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    There's a new version of Smart Localization (2.3.0) available on the Asset Store!

    Changelog:
    • Added localised font files (PRO only)
    • Improved csv parsing
    • Changed store presence generator to work with Unity 5.2
    • Updated compatibility issues for Unity 5.2
    • Minor bug fixes
     
  43. chickenW

    chickenW

    Joined:
    Jul 19, 2012
    Posts:
    2
    hello, looks like Smart Localisation (2.3.0) FREE is not working with Windows Store Universal 8.1. It makes no error, no crash... just not present at runtime...

    just work fine with Windows Store Phone 8.1.
     
  44. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That doesn't sound good :/ Can you give me information on what system(windows, mac) you are on as well as the Unity3D version?

    We'll look into it :)

    If anyone else has the same issues, please let us know.
     
  45. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
  46. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    We just made a new tutorial video that contains the absolute basics of Smart Localization.



    If you'd like a tutorial on a Smart Localization feature or concept - let us know.
     
  47. JEDressler

    JEDressler

    Joined:
    Apr 18, 2015
    Posts:
    7
    Hi!

    First at all, great plugin ...
    Everything works well as long as i'm working inside Unity. But when i try to execute my app on my Windows Phone 8.1, i get these errors:

    Code (CSharp):
    1. The script behaviour 'SmartLocalization.LanguageManager' could not be instantiated!
    2. (Filename: C:/buildslave/unity/build/Runtime/Mono/MonoBehaviour.cpp Line: 1586)
    3.  
    4.  
    5. Exception: Object reference not set to an instance of an object.
    6. Type: System.NullReferenceException
    7. Module: Assembly-CSharp
    8. InnerException: <No Data>
    9. AdditionalInfo:<No Data>
    10.    at Startup.loadLanguageManager()
    11.    at Startup.$Invoke4(Int64 instance, Int64* args)
    12.    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    13. (Filename:  Line: 0)
    14.  
    15.  
    16. NullReferenceException: Object reference not set to an instance of an object.
    17.    at Startup.loadLanguageManager()
    18.    at Startup.$Invoke4(Int64 instance, Int64* args)
    19.    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    20. (Filename: <Unknown> Line: 0)
    And this is the script:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using SmartLocalization;
    5.  
    6. public class Startup : MonoBehaviour {
    7.  
    8.     public Text title;
    9.     public Text description;
    10.  
    11.     private SystemLanguage systemLanguage;
    12.     private string languageShortcut;
    13.  
    14.     // Use this for initialization
    15.     void Start () {
    16.         loadSystemLanguage();
    17.         loadLanguageManager();
    18.     }
    19.    
    20.     // Update is called once per frame
    21.     void Update () {
    22.         if (Input.GetKey(KeyCode.Escape)) {
    23.             Application.Quit();
    24.         }
    25.     }
    26.  
    27.     // Use this for shutdown
    28.     void OnDestroy() {
    29.         if (LanguageManager.HasInstance) {
    30.             LanguageManager.Instance.OnChangeLanguage -= OnLanguageChanged;
    31.         }
    32.     }
    33.  
    34.     private void loadSystemLanguage() {
    35.         this.systemLanguage = Application.systemLanguage;
    36.         switch (this.systemLanguage) {
    37.             case(SystemLanguage.German):
    38.                 this.languageShortcut = "de";
    39.                 break;
    40.             case (SystemLanguage.English):
    41.                 this.languageShortcut = "en";
    42.                 break;
    43.             case (SystemLanguage.French):
    44.                 this.languageShortcut = "fr";
    45.                 break;
    46.             default:
    47.                 this.languageShortcut = "en";
    48.                 break;
    49.         }
    50.     }
    51.  
    52.     private void loadLanguageManager() {
    53.         LanguageManager.Instance.OnChangeLanguage += OnLanguageChanged;
    54.         LanguageManager.Instance.ChangeLanguage(this.languageShortcut);
    55.     }
    56.  
    57.     void OnLanguageChanged(LanguageManager thisLanguageManager) {
    58.         this.title.text = thisLanguageManager.GetTextValue("key.title");
    59.         this.description.text = thisLanguageManager.GetTextValue("key.description");
    60.     }
    61. }
    62.  
    I hope you could help me. I tried several options, watched the tutorial, tried written guides, but nothing :(
     
  48. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Is that the full error log? If not, can you send me the log and other data to janetechgames[at]gmail[dot]com and I will have a look. Could you also send me the version of SmartLocalization, what OS you have and what version of Unity you have.

    Such a weird error - We will look into it. Any more info you have might help and would be much appreciated :)
     
  49. JEDressler

    JEDressler

    Joined:
    Apr 18, 2015
    Posts:
    7
    It's the full error log.
    I have Windows 8 with SmartLocalization 2.3.0 and Unity 5.1.1f1
    The error appears in the error log of Microsoft Visual Studio and on my Windows Phone 8.1

    I tried .NET compiler and Mono compiler, but nothing changed.
     
  50. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Does it work in the simulator for windows phone? I've been trying to reproduce your error with a couple of different unity versions and it works for me in the simulator.

    Unfortunately, I don't have an actual windows phone to test this with. I need to use the simulator :/

    Can you give me steps to reproduce? With the same settings? Or maybe send me an example project that you know has this issue?