Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] Smart Localization for Unity3D

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

  1. Spirit02

    Spirit02

    Joined:
    Jun 30, 2016
    Posts:
    2
    Niklas, just updated to v2.4.2 free (did have whatever previous release was) from within Unity 5.3.5f1 Personal, and all the localized text components I had attached to game objects have disappeared - now say 'Missing (Mono Script)'.
    Thankfully, re-selecting the appropriate script seems to keep the key information intact.

    Did you happen to move its location? I only have a relatively small project at this stage, but I imagine manually re-selecting all instances of said script would potentially be rather daunting.
     
    Last edited: Jun 30, 2016
  2. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi, no - nothing have been moved. The update to the free version (2.4.2) was a very small one.

    Could it be related to this issue? - https://issuetracker.unity3d.com/is...-but-is-not-known-in-guidmapper-dot-dot-dot-1
    http://forum.unity3d.com/threads/suddenly-all-ui-scripts-missing.322760/

    It says in the issue tracker that it's been solved, but the comments say that people still have issues with it. Can you try as one of the comments say and remove the Library folder and try? And report here if it succeeded? :)

    Thanks,
    /Niklas
     
  3. Spirit02

    Spirit02

    Joined:
    Jun 30, 2016
    Posts:
    2
    Does indeed seem to be related - I just imported 2.4.2 into an earlier backup of my project, and I get a whole bunch of "Overriding existing asset with new GUID from package, this may break links within your project to package assets" in the console, followed by a single: NullReferenceException: Object not set etc etc UnityEngine.UI.Graphic.OnRebuildRequested ().

    Closed Unity, deleted the Library folder and re-opened. Unity rebuilt the Library. I re-opened my scene, hit play, and the console is filled with 'The referenced script on this Behaviour (etc) is missing'. It is only the localized text scripts that are missing though. All my other attached scripts seem to still be there.

    So that doesn't appear to solve the problem.

    I'd already manually re-selected all the instances in my project, so I've fixed the problem, but thought you'd want to know anyway.
     
  4. Morgenstern_1

    Morgenstern_1

    Joined:
    Jul 1, 2013
    Posts:
    34
    Hi guys, we've been using Smart Localization for a game we're working on and so far have found it to be great. I'm working on optimisation at the moment though and one thing that's flagging up is that hooking into the LanguageManager OnChangeLanguage event seems to be generating a huge amount of garbage for some reason.

    Whenever our pause menu is enabled all the required text fields on it (76 on this particular screen) hook into the OnChangeLanguage event and I see a massive garbage spike in the profiler of 0.7Mb! This seems insanely high for just hooking into an event, what is going on behind the scenes to cause this? And can it be reduced somehow? This happens every single time the pause menu is opened (they hook in during OnEnable and unhook in OnDisable) and is a bit of a problem!
     
  5. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That event is just a regular delegate. No real logic is applied to it. It just lets people register, deregister and then the LanguageManager invokes it when the language changes.

    This is basically how it looks in the plugin.

    Code (csharp):
    1.  
    2. public delegate void ChangeLanguageEventHandler(LanguageManager thisLanguageManager);
    3.  
    4. public class LanguageManager : MonoBehaviour
    5. {
    6.      public ChangeLanguageEventHandler OnChangeLanguage;
    7. }
    8.  
    Is it just this event? How does it compare with just registering on another (dummy)event?
     
  6. Satavr

    Satavr

    Joined:
    May 20, 2015
    Posts:
    2

    I 'm try to use this code. It work for the first time, but when I switch level it doesn't change language. Seems like OnLanguageChanged method is not assigned.
     
  7. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
  8. Satavr

    Satavr

    Joined:
    May 20, 2015
    Posts:
    2
  9. cephalo2

    cephalo2

    Joined:
    Feb 25, 2016
    Posts:
    239
    This seems like the best way to localize! I have a quick question. The 'GetFont' method isn't recognized in LanguageManager.Instance for me. Is that something that only comes with the paid version perhaps?
     
  10. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Ok - I'm glad you found a solution :)

    Yes, that's correct. The font localization is a PRO only feature.

    You can find a product comparison here - http://www.janetech.co/product-comparison/
     
  11. funbites

    funbites

    Joined:
    Oct 9, 2015
    Posts:
    17
    Hi, great tool!

    We have an in-house localization tool, but I think we'll change to Smart Localization, it's smarter than ours. I have just one issue here. Can I get a value from default language or key's comment at editor? I have a component that asks for the string's key and I would like to give the user a preview of what is the content of the key at the editor.

    Thanks!
     
  12. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Yes, It is possible to get the root values from the editor. Here's a guide on how to do it: http://www.janetech.co/blog/2016/1/...localization-getting-language-values-and-keys

    Hope that helps.
     
  13. funbites

    funbites

    Joined:
    Oct 9, 2015
    Posts:
    17
  14. Oksana-Iashchuk

    Oksana-Iashchuk

    Joined:
    Sep 10, 2012
    Posts:
    111
    Have a look at https://www.assetstore.unity3d.com/en/#!/content/73930 Localizer, it does save controls layout as well.
     
  15. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Great! I'm glad it worked.

    I would appreciate you not advertising other localization plugins in the support thread for my localization plugin. Please do it in other threads instead. Thanks.
     
  16. greentreelabs

    greentreelabs

    Joined:
    Nov 6, 2016
    Posts:
    18
    Hi there,

    thank you a lot for such a great tool! I have one question though. How can I translate the UI Texts? I've searched in forums and Google but can't find an answer.
     
  17. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi,

    There's a class called LocalizedText that you can put on the game objects with the uGUI Text Component on them. From there you should be able to choose a key.

    I made a github repositoryas an example from a Unity Sample a while ago that did this if you need more information on how to use it - https://github.com/NiklasBorglund/SampleUIExample-SmartLocalization
     
  18. greentreelabs

    greentreelabs

    Joined:
    Nov 6, 2016
    Posts:
    18
    Cool, thank you Niklas! Last question, is there a way to manage placeholders? For example:

    "Welcome back {{name}}! How're you doing today?"

    or I have to simply replace it from a script?
     
  19. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Sure, you can use the string.Format() method in .NET to do that.

    Lets say you have a string that looks like the one below:
    Code (csharp):
    1.  
    2. var myString = "I have {0} score";
    3.  
    To replace that {0} placeholder, you can use the string.format method as shown below
    Code (csharp):
    1.  
    2. var myString = "I have {0} score";
    3. var currentScore = 1000;
    4. var myAlteredString = String.Format(myString, currentScore);
    5.  
    The output of the above code would be. "I have 1000 score".

    Then if you want to replace multiple place holder, just continue with {1} {2} and so on like in the example below.
    Code (csharp):
    1.  
    2. var myString = "I have {0} score and my name is {1}";
    3. var currentScore = 1000;
    4. var name = "Niklas"
    5. var myAlteredString = String.Format(myString, currentScore, name);
    6.  
    The output of this one would be. "I have a 1000 score and my name is Niklas"
     
  20. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    77
    Hi, I'm very interested in using this asset for production. It beats having to rewrite my own again.

    I do have a concern about games with a large amount of text. Is it possible to use multiple language root files? For example, a UI_Strings file, and a Dialogue_Strings file? It would get very messy having to squeeze hundreds if not thousands of lines into a single file.

    Also, what is the overhead like with the GetTextValue() method? Is this something that should be avoided on every frame at runtime?

    Thanks!
     
  21. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Unfortunately, there's no feature for multiple root files in Smart Localization. I am working on that feature for Smart Localization 3.X, but I can't say when that will be released.
    The GetTextValue just gets a value from a dictionary, so it is fast with a near complexity of O(1), but I would recommend that you get the language values at the start of your application or by listening to the OnLanguageChanged event in the LanguageManager and get them there.
     
  22. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    77
    Thanks for the response Niklas! I've purchased a license and look forward to any possible update!

    One last question, do you think you will ever (or currently) support .resx files? Thanks.
     
  23. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Yeah, the language files in the Smart Localization project is currently based on .resx. You can find them in the SmartLocalizationWorkspace folder.
     
  24. boubouk50

    boubouk50

    Joined:
    Jul 10, 2014
    Posts:
    15
    Hello there.
    I'm currently having a problem with SmartLocalization and GameObjects that are not destroyed between scenes. (I'm using Unity 5.2.0f3)
    Let me explain:
    I have a (Canvas + Panel + Text) group that needs to remain between scene. This is a toast to inform the user that he has to press twice the escape button to escape the game. The text has a LocalizedText script attached on it because its content needs to be translated, of course.
    This is the only Text object that is not detroyed between scenes, and this is the only one who doesn't get updated. Every other text objects in the scenes are updated.
    Actually it only updates at Start of the app (when it is still in its own scene), but at first scene changes, it's not getting updated anymore. LanguageManager.Instance.ChangeLanguage () can be called at any moment from a button.
    Can you help me fixing that?

    Thank you.
    Keep up the good work.
     
  25. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi,

    It sounds like you need to make the LanguageManager to persist between scenes. You can find more information here: http://www.janetech.co/blog/2016/4/24/setting-the-languagemanager-to-persist-between-scenes
     
  26. boubouk50

    boubouk50

    Joined:
    Jul 10, 2014
    Posts:
    15
    That works, thanks a lot. ;)
    (And sorry for the redundant question, it's seems to be a recurring problem. I've read older post but didn't understood at first, now makes sense. I Should rehearse my english :oops:)
     
  27. kaplica

    kaplica

    Joined:
    Feb 20, 2014
    Posts:
    87
    Hi Niklas, How would I got about translating my dynamic text on one label? I have 5,000 different text that goes only on one label from an xml file.
     
  28. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi, do you have a system in mind for picking the right text for the label? In that case, you need to add all the 5000 texts to the Smart Localization system with unique keys and then you create a script that sets the correct text on the label with LocalizationManager.Instance.GetTextValue("your_unique_key");
     
  29. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    1,924
    Using newest unity beta version, just before suddenly unity shows error when opening working project, says some missing files, actually nothing there, I dont know maybe my newest bought external ssd has disc error,

    anyway, after reimport all assets, project opened, but scene completely broken, nothing there, one script become full of unknown unicode, messed, and this asset,

    smartlocalization too, says

    ----------
    Cannot load language file - language Data In ResX is null!
    ------------

    already tried delete SmartLocalization folder and reimported from store, but this error still there, if I open SL window, there is no initial status, but past status I worked. But when I click [Edit Root Language File], above error shows, nothing I can do it.

    This asset has basic error like this.

    When it messed, there is no way to restart and reset all setting. I can't restart. And also I completed losed all input texts assets translated.
     
  30. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That sounds odd. Something must have gone wrong when you updated Unity. Do you have a version control system to temporarily roll back any changes?


    Anyway, you could try the following to reset your SmartLocalization project (make sure to backup your project before this!):
    • Check if you have any files in SmartLocalizationWorkspace->Data->LanguageData
    • If you do, copy all the .resx files into another location on your computer
    • Remove the SmartLocalizationWorkspace folder (again, backup your project before this)
    • Open the Smart Localization window and create a new workspace
    • Copy the .resx files back into SmartLocalizationWorkspace->Data->LanguageData
    Hope that helps
     
  31. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    IMPORTANT NOTICE

    Hi all,

    We’ve been working on Smart Localization for over three years now, and it’s been extremely fun and exciting for us to see our product being used in your games.
    Supporting other languages can open up your game to a whole new audience that would never have played it otherwise - and we are glad that we could provide the tools for many of you to ease that process during the years.

    Unfortunately, Smart Localization is a product that never gave us any economical safety - so we’ve developed it as a side project just for fun, alongside our respective full time jobs. It enabled us to buy coffee, and we’re eternally grateful for that ;)

    In light of this, I regret to inform you that we have decided to discontinue the development of Smart Localization.

    This is mainly because of two reasons. Firstly, we are starting to feel that we cannot give Smart Localization the development time it needs any longer. About a year ago, we started to rewrite the project to Smart Localization 3.0, with multiple file support and a completely unit & system tested code base. But even now, when a lot of that is done - we still have much to do and we feel that we can’t keep up with the increase in demands of updating the product.
    Secondly, I have just got a new job within the game industry and signed a non-compete clause that prevents me from working any further with this.

    The PRO version will be taken down from the store today, but we have also put up the project open source on GitHub with an MIT-license which you can find here: https://github.com/NiklasBorglund/Smart-Localization-2

    We are very sorry for the inconvenience. We’d would recommend that you start looking for other localization solutions for your projects. We’ve never tried it, but we’ve heard that I2 Localization should be very good: https://www.assetstore.unity3d.com/en/#!/content/14884

    Regards,
    Niklas
     
    Muckel likes this.
  32. Dmitry-Volevodz

    Dmitry-Volevodz

    Joined:
    Apr 6, 2014
    Posts:
    10
    Yeah I guess that's life, but moving to another paid plugin that may go MIA next month doesn't sound like excellent idea.
     
  33. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    242
    Thank you for your work on this, and thanks for making the system open source - I hope that there will be a couple of people to carry on the torch :) Good luck with your new job!
     
    NiklasBorglund likes this.
  34. DevXDeveloper

    DevXDeveloper

    Joined:
    Nov 8, 2016
    Posts:
    11
  35. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    298
    Hi does smart localisation allow to keep localisation files in resources after game is built so it can be easly updated without rebuilding app?
     
  36. softmarshmallow

    softmarshmallow

    Joined:
    Jan 29, 2016
    Posts:
    7
    why no longer available??
     
  37. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    298
    You can download it from github.
     
  38. DevXDeveloper

    DevXDeveloper

    Joined:
    Nov 8, 2016
    Posts:
    11
    Yes, this is possible within certain limits, the localization of lines from the code is supported for ready assemblies, i.e. You can even localize third-party dlls without source codes
    (Devxunity obfuscator, DevXUnity Localization)
     
  39. Ailrau

    Ailrau

    Joined:
    Feb 5, 2017
    Posts:
    21
    Hey! I have a problem with smart localization

    whenever i upgraded mu unity to 2017.4.2f smart localization is broked i upgrade latest version from github but problem is still same Localized Text key select button is not showing and when i select localized text object unity give me this error;

    Code (CSharp):
    1. ArgumentNullException: Argument cannot be null.
    2. Parameter name: dictionary
    3. System.Collections.Generic.Dictionary`2[System.String,SmartLocalization.LocalizedObject]..ctor (IDictionary`2 dictionary, IEqualityComparer`1 comparer) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:245)
    4. System.Collections.Generic.Dictionary`2[System.String,SmartLocalization.LocalizedObject]..ctor (IDictionary`2 dictionary)
    5. SmartLocalization.Editor.LanguageHandlerEditor.LoadParsedLanguageFile (System.String languageCode, Boolean isRoot) (at Assets/SmartLocalization/Scripts/Editor/FileOperations/LanguageHandlerEditor.cs:398)
    6. SmartLocalization.Editor.TranslateLanguageWindow.Initialize (SmartLocalization.SmartCultureInfo thisCultureInfo, Boolean forceNewLanguage) (at Assets/SmartLocalization/Scripts/Editor/EditorWindows/TranslateLanguageWindow.cs:99)
    7. SmartLocalization.Editor.TranslateLanguageWindow.OnGUI () (at Assets/SmartLocalization/Scripts/Editor/EditorWindows/TranslateLanguageWindow.cs:267)
    8. 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/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    9. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    10. 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/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    11. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    12. UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
    13. UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
    14. UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255)
    15. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    I am pretty sure value is not null and language data is not empty

    OH I FOUND IT MY Assets\SmartLocalizationWorkspace\AutoGenerated\Resources\Language.txt is empty but why?
     
    Last edited: May 6, 2018
  40. fred_gds

    fred_gds

    Joined:
    Sep 20, 2012
    Posts:
    184
    Hey there,

    I was wondering whether there is a method to add keys to the root language by script. I have collected all my strings that need to be translated in an xml file and I would like to avoid entering them by hand, so I am sure that there must be an easier way, but I couldn't figure it out. Therefore it would be great if you could help me out with that.

    EDIT: I found a solution by going through the EditRootLanguageFileWindow.cs script. Not pretty, but by tackling directly the OnKeyAdded function I was able to insert all my strings.
     
    Last edited: Jul 6, 2018
  41. Danielsantalla

    Danielsantalla

    Joined:
    Jan 7, 2015
    Posts:
    30
    Hey guys, is this plugin still working on Unity 2018.2.3?
     
  42. overfile

    overfile

    Joined:
    Oct 21, 2013
    Posts:
    27
    Sorry, in Unity 2017.x perfectly works but in 2018 i have a bug with the editor.
     
  43. Chichkan

    Chichkan

    Joined:
    Jun 15, 2015
    Posts:
    5
unityunity