Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Smart Localization for Unity3D

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

  1. Nazarick

    Nazarick

    Joined:
    Jan 29, 2014
    Posts:
    27
    @NiklasBorglund :

    Hi,

    No problems for the late reply. I have not had the opportunity to use Unity much these days so I'm in no hurry.

    Hoping to version 4.6, the integration is done nicely.

    Thank you for your reply, I expect your return for more information.
     
  2. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi All!

    I just submitted an update to the asset store with what I thought was the most urgent fixes.

    Changelist v.2004
    ------------------------------------
    * Made fix for event issue when changing language on iOS (JIT-Compile issue)
    * Fixed multiline issue for text lines in the translate window
    * Fixed multiline issue in CSV Import/Export

    You can now simply press enter in the translate window to get a new line.

    As usual, it will take a few days for it to pass the asset store submission process - so if you would like it right now, send me(@NiklasBorglund ) or @zuric a PM with your email address and we will send the updated dlls to you asap.


    I've added the ability to choose a default language from the editor window in our todo list on the trello board.

    This is how I'm getting a list of the available/non-available languages to use in EditorGUILayout.Popup method:
    Code (csharp):
    1.  
    2. var allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
    3. var availableCultures = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);
    4. var nonAvailableCultures = LanguageHandlerEditor.GetNonAvailableLanguages(allCultures);
    5.  
    That will give you lists with instances of SmartCultureInfo. From those lists I take the SmartCultureInfo.englishName from each one and use it to create the array.
    The availableCultures will give you a list of created languages, and the nonAvailable will give you a list of all the languages that hasn't been created(yet)

    Let me know if you would like it to work differently and If so - how - and I'm sure we could work something out :)
     
  3. Nazarick

    Nazarick

    Joined:
    Jan 29, 2014
    Posts:
    27
    Hi NIklasBorglund,

    I'll try to be as descriptive as possible, because there are some things I do not understand. I'm French, so English very technique is not always easy to explain, so if I express myself badly does not hesitate to tell me. I try to rephrase if necessary.

    Code (csharp):
    1. SmartCultureInfoCollection allCultures = SmartCultureInfoCollection.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
    With your code above, I end up with several errors context.

    I must surely take me wrong in my opinion. I have the Namespace SmartLocalization clear early code, but now I admit to not knowing where the problem can come and especially why he does not know the three references cited above.

    I hope my English is readable and understandable especially for the shot. Sorry to abuse your patience like this ^.^"

    Thank you for your answers to my messages.

    LudlowFx
     
  4. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Yes, I forgot to tell you. Those methods are in another namespace called SmartLocalization.Editor

    Try adding this with the other using statements in your code:

    Code (csharp):
    1.  
    2. using SmartLocalization.Editor;
    3.  
     
  5. Nazarick

    Nazarick

    Joined:
    Jan 29, 2014
    Posts:
    27
    Hello,

    I'm idiot sometimes. This Namespace, i read it last night on page number two of this topic. Suddenly yes, it works with this namespace and I have no errors now.

    Thank you very much for your help :)
     
  6. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    Hi,
    Cool and useful tool!

    I'm trying to extend a custom inspector I have to show the available languages and keys.
    I managed to show the languages, but I can't find how to access the list of keys.

    Can you help?
     
  7. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi dorpeleg!

    I'm glad you like it :)

    There are a few different ways to only get the keys/root values. They can be found in the SmartLocalization.Editor window.

    The way I use it to only get a popup with all the keys and a few buttons to choose the key is with the LocalizedKeySelector - class. That will produce a ready made GUI to use and got some features to only show keys of a certain type.
    The downside of using this method is that you will not be able to customize the GUI, and I cannot promise that it won't change.
    Code (csharp):
    1.  
    2. using SmartLocalization.Editor;
    3.  
    4. public override void OnInspectorGUI()
    5. {
    6.     string selectedKey= LocalizedKeySelector.SelectKeyGUI(selectedKey, true, LocalizedObjectType.STRING);
    7. }
    8.  
    The other way is to get the root value dictionary. You got two methods you can use.

    First one is the LoadParsedLanguageFile Method. If you pass in null as the language code and true for the isRoot parameter, you will get a list of parsed values.
    What I mean with parsed values is that all the type keys(except string) has a type prefix to the key. That will be stripped off if you use this. And instead of a string value, you will get a LocalizedObject.
    You can use the properties in the LocalizedObject to directly get the actual object (or text string) depending on the type.
    But since this is the root, the values are not of importance.

    Code (csharp):
    1.  
    2. using SmartLocalization.Editor;
    3.  
    4. void MyMethod()
    5. {
    6.   Dictionary<string, LocalizedObject> values = LanguageHandlerEditor.LoadParsedLanguageFile(null, true);
    7. }
    8.  
    And finally if you'd like the raw <string,string> dictionary you can use this:

    Code (csharp):
    1.  
    2. using SmartLocalization.Editor;
    3.  
    4. void MyMethod()
    5. {
    6.   Dictionary<string, string> values = LanguageHandlerEditor.LoadLanguageFile(null, true);
    7. }
    8.  
    That one will return all the keys and root comments with all the prefixes.

    Hope that helps,
    /Niklas
     
    Crazydadz likes this.
  8. Nazarick

    Nazarick

    Joined:
    Jan 29, 2014
    Posts:
    27
    Hi,

    After some discussion on the forum PlayMaker and some tests, I'd like to open a discussion here to see if it was possible to create a bridge between PlayMaker and SmartLocalization.

    I'm not a genius programmer, but it based on the package Kdimas I slightly expanded its actions within PlayMaker and would love to have your opinion and how to improve. There are many other assets of multi-language, but I find SmartLocalization really well and can be used in PlayMaker so "clean" would be really fabulous ^^

    At the moment I have not added a lot of possibilities, but here's a little screenshot and a package containing the new files.

    Note: This Package includes version 2.0 v2.004 of SmartLocalization (it has not been modified) because it has a sample scene.

    BUT does not contain PlayMaker because it is not free !!! There is just the folder related to SmartLocalization and sample scene files!

    (View this image full size in attached Files)




    I will also open the discussion on this package on the forum PlayMaker to see if others more knowledgeable than I would be interested to create something clean.


    1 Create a new blank project Unity3D
    2 Import PlayMaker
    3 Import SmartLocalizationPlayMaker_BridgeDemo.unitypackage
    4 Start scene "ExampleBridgeScene" in the "_Example Scene" folder
    5 And click Play.

    Normally, there should be no error in this manner.

    A webplayer for non PlayMaker user : https://dl.dropboxusercontent.com/u...0.1/PlayMaker_SmartLocalization_Beta_0.1.html
     

    Attached Files:

  9. Nazarick

    Nazarick

    Joined:
    Jan 29, 2014
    Posts:
    27
    Sorry for the double post ^^"

    New Version. v0.1 (Here on PlayMaker Forum)

    A slight update with some fixes were made. And the addition of new actions!

    - Fixed some minor bugs
    - Adding the event system at "Set Current Language"
    - Adding the action "Get Loaded Language Name"
    - Adding the action "Get Number Of Supported Languages"


    In Think :

    - Add "defaultLanguage" ? Where is SetDefaultLanguage ?
    - Display the list of languages available in "Set Current Language" instead of a text field (no idea how yet)
    - Check with regulars Playmaker if need code optimization ^^


    As already stated, I am not a great expert programer code of Playmaker so if you want to help me optimize the code please tell me

    New Webplayer Test : http://urlz.fr/A9D

    EDIT :

    I think, I posted it here, but if it's annoying, let me know. I admit I was not sure where to post this on this forum.
     

    Attached Files:

    Last edited: Aug 19, 2014
  10. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    Thanks Niklas

    I've implemented the first option (with the ready made GUI) and it works very well.
    But I do have an issue with it.
    Every time I select the object with my custom inspector, the selected key goes back to "--- No Key Selected ---".
    So I was thinking about using one of the other options you suggested.
    But, I can't use GUI popup with Dictionary because it has no index.
    Any ideas?
     
  11. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    This is great! It's very much appreciated! :)

    I'd recommend that you push the code to a repository or something (like Github), with a license of your choosing - so that people can always have a place to go to for the latest version.
    Unfortunately, I don't own a copy of PlayMaker - so It'll be hard for me to help out until I manage to get a copy.

    You have to save the selection with the SelectKeyGUI for it to stick. The first parameter in the method is called currentKey. This is where you specify the key that was chosen. Like this:

    Code (csharp):
    1.  
    2. string selectedKey = null;
    3.  
    4. void Awake()
    5. {
    6.        //This is where I set my selected key(if one) otherwise, set to null
    7.        selectedKey = ((MyClass)target).localizedKey;
    8. }
    9.  
    10. public override void OnInspectorGUI()
    11. {
    12.        base.OnInspectorGUI();
    13.        // This is where I send in my selected key and the SelectKeyGUI sends back the selected one
    14.        //It'll send another one back if the user selected a different one.
    15.        selectedKey = LocalizedKeySelector.SelectKeyGUI(selectedKey, true, LocalizedObjectType.STRING);
    16. }
    17.  
    To use one of the other options, you need to save the keys to a List<string> or an array that you can use with the GUI Popup List.
    You either iterate through the list of KeyValuePairs or you can use the Dictionary.Keys Property to get a KeyCollection.
     
  12. Nazarick

    Nazarick

    Joined:
    Jan 29, 2014
    Posts:
    27
    Hi,

    This is only a small contribution and can be largely improved with time ^^

    I have never used a system like Github before today, I confess to being a little lost, but I still managed to upload the necessary scripts. (No example scene, just the minimum). The license, I admit to not knowing what to choose as a result, I chose the same as you. MIT!

    Here is the link to the Github page: https://github.com/LudlowFx/PlayMaker_SmartLocalization

    And here on Playmaker Forum : http://hutonggames.com/playmakerforum/index.php?topic=8146.msg39267

    It has gone to version 0.1.2 (small reorganization names, descriptions and actions for clarity).

    I would try to improve it over time and maintain its operation when an update of your asset or that of PlayMaker happen.

    Bye :)
     
    Last edited: Aug 21, 2014
  13. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    Niklas, your solution was so simple!
    I don't know how I didn't come up with it myself.

    Thanks!
     
  14. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    We just submitted version 2.005 to the store. We have made a solution that will detect the localized languages in Google Play Store and App Store.

    However, this store functionality could use some testing. So if anyone is willing to test this and report back to us, we would greatly appreciate it.

    Changelist Version 2.005
    -------------------
    * Added Beta version of automatically detecting localized languages in Google Play Store and App Store.
    * Added CSV-Update functionality and window

    As always, few days before it hits the store. Contact me(@NiklasBorglund) or @zuric if you want it sooner.

    Thanks,
    Niklas
     
  15. b8rt

    b8rt

    Joined:
    Feb 11, 2013
    Posts:
    2
    Hi,

    is their a possibility to add parameters in a sentence. I want to add an amount to a sentence.
    ie. "Please select %AMOUNT% clusters".
     
  16. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Sure, you can use String.Format to do that.
    ex.

    If you set your text value like this - "Please select {0} clusters".

    Then you can use it in code like this:
    Code (csharp):
    1.  
    2.  
    3. int currentAmountOfClusters = 100;
    4. string myLocalizedLabelValue = null;
    5.  
    6. void MyMethod()
    7. {
    8.       string myLocalizedValue = LanguageManager.Instance.GetTextValue("MyLocalizedValue");
    9.       myLocalizedLabelValue = string.Format(myLocalizedValue, currentAmountOfClusters);
    10. }
    11.  
    12.  
     
  17. b8rt

    b8rt

    Joined:
    Feb 11, 2013
    Posts:
    2
    Works like a charm.

    Thanks for the quick help.

    Kind Regards
    Bart
     
  18. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    Hey,
    I seem to have a weird behavior sometimes.
    Sometimes the LanguageManager is created more then once (I think this only happens in editor).
    I've decompiled the code just to see whats going on and I can see you only checking if the instance is null and if it is, you just create a new one.
    Could you please add a 'find' test as well? so if the instance is null, try to find an instance of that component first, and only if you can't find it, create a new one.
     
  19. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hmm, that should not happen. I'll look into it.

    It only happens when you play the game in the editor, right? Not when using editor windows?

    Until I fix it, set the LanguageManager script to run before anything else. The Awake()-method should set the instance.
     
  20. NigmaLab

    NigmaLab

    Joined:
    Aug 30, 2014
    Posts:
    7
    Hi,
    I'm trying to use it on our Windows 8 Store App, but it throws an exception at launch:
    Exception: Unable to cast object of type 'SmartLocalization.LanguageManager' to type 'UnityEngine.IUnitySerializable'.
    Type: System.InvalidCastException
    Module: UnityEngine
    InnerException: <No Data>
    AdditionalInfo:<No Data>
    at UnityEngine.IUnitySerializable.$Invoke1(Int64 instance, Int64* args)
    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)

    (Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Scripting/WinRTUtility.cpp Line: 88)

    Thanks!
     
  21. NigmaLab

    NigmaLab

    Joined:
    Aug 30, 2014
    Posts:
    7
  22. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That's odd. I've been getting reports that it works on WP8 and Win8, but obviously it doesn't :/

    So thank you for the detective work - never used that site(scan.xamarin) before - I'll start using it from now on :)

    Will fix the issues and add it to the next version.
     
  23. Vesa

    Vesa

    Joined:
    Dec 14, 2012
    Posts:
    4
    Hi,

    LanguageManager initialization fails at runtime in iOS. It works on Android and Unity Editor. Smart Localization version is 2.0 v2.005.

    Error message:
    LanguageManager is not initialized properly!

    NotSupportedException: Derived classes must provide an implementation.
    at System.Type.GetGenericTypeDefinition () [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type runtimeType, System.String xmlDataType) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type type) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlReflectionImporter.CreateMapMember (System.Type declaringType, System.Xml.Serialization.XmlReflectionMember rmember, System.String defaultNamespace) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
    Rethrow as InvalidOperationException: There was an error reflecting field 'cultureInfos'.
    at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
    Rethrow as InvalidOperationException: There was an error reflecting type 'SmartLocalization.SmartCultureInfoCollection'.
    at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.Xml.Serialization.XmlAttributeOverrides overrides, System.Type[] extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) [0x00000] in <filename unknown>:0
    at SmartLocalization.SmartCultureInfoCollection.Deserialize (UnityEngine.TextAsset xmlFile) [0x00000] in <filename unknown>:0
    at SmartLocalization.LanguageManager.LoadAvailableLanguages () [0x00000] in <filename unknown>:0
    at SmartLocalization.LanguageManager.Awake () [0x00000] in <filename unknown>:0

    Thanks
     
  24. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Thanks for the stack trace. Very helpful.

    I'll rewrite and I'll make a custom xml-reading procedure for runtime instead of using the XMLSerializer. Should work anyway though - what kind of stripping level do you use? (if any)
     
  25. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    Hey, any info on my issue?
    Its really annoying to get 10+ dupes of the manger appearing....
    It happens in both play time (editor) and even when just opening a scene with my component that uses it...
    In short, every time I access the instance in editor (play time or not) I get dupes.
     
  26. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    I am unable to reproduce the issue. Can you give me the necessary steps to see the bug happen alt. post some of your code?
     
  27. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    I have a code that runs in editor using [ExecuteInEditMode]
    and all I'm doing is:

    Code (CSharp):
    1.             // initializing language localization
    2.             _languageManager = LanguageManager.Instance;
    3.             var systemLanguage = _languageManager.GetSupportedSystemLanguageCode();
    4.             if(_languageManager.IsLanguageSupported(systemLanguage))
    5.             {
    6.                 _languageManager.ChangeLanguage(systemLanguage);
    7.             }
    8.             else
    9.             {
    10.                 _languageManager.ChangeLanguage(_languageManager.defaultLanguage);
    11.             }
    This code runs on the Start method.
     
  28. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Ok. The problem is that the LanguageManager isn't created to be used in editor scripts at all. Add these lines of code right after your code block where you use it in the editor.

    Code (csharp):
    1.  
    2. #if UNITY_EDITOR
    3.         if(!Application.isPlaying)
    4.         {
    5.             GameObject.DestroyImmediate(_languageManager.gameObject);
    6.         }
    7. #endif
    8.  
    I'm guessing you want the objects registered to change the language delegate to invoke even when the Game is not playing? If so, please tell me how you would like to use a feature like that, and how you think it should work, and we'll try and create some handy editor methods for that instead :)

    Hope that helps,

    /Niklas
     
  29. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    I actually think you can make a much better solution that will solve any kind of problems.
    Something like:
    Code (CSharp):
    1. if(Instance == null)
    2. {
    3.     #if UNITY_EDITOR
    4.         Instance = FindObjectOfType(typeof(LanguageManager));
    5.     #endif
    6.     if(Instance == null)
    7.     {
    8.         // do the rest of your singleton code here
    9.    }
    10. }
    What do you think?
     
  30. Vesa

    Vesa

    Joined:
    Dec 14, 2012
    Posts:
    4
    Thanks for investigating the issue. I'm using UseMicroMSCorlib stripping level.
     
  31. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    @dorpeleg : Sure, that should do it. Adding it.

    @Vesa , @dorpeleg , @NigmaLab: I have a beta version(2.1) available if you want it. It got quite a few changes to it and it is basically untested, but it might solve your problems. So you'll have to use it at your own risk. DM: me or @zuric with your email if you want it.

    That same offer goes for anyone that want v.2.1. It has not been pushed to the store yet, because we need to test it.
     
  32. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    @NiklasBorglund Thanks!
    Its not super urgent yet, and I don't have time to test it myself.
    I think i'll wait until you update the store or until it will be more urgent to me.
     
  33. umar43

    umar43

    Joined:
    Sep 18, 2013
    Posts:
    6
    First of all thanks for providing this helping tool for localisation. Its awesome.

    I want to create/update language at runtime through code using CSV downloaded from server with new/updated keys and values. I am unable to find any solution. Please guide me in this regard. This important and urgent.



    Thanks in advance.
     
  34. umar43

    umar43

    Joined:
    Sep 18, 2013
    Posts:
    6
    First of all thanks for providing this helping tool for localization. Its awesome.
    I want to create/update language at runtime through code using CSV downloaded from server with new/updated keys and values. I am unable to find any solution. Please guide me in this regard. This important and urgent.

    Thanks in advance.
     
  35. umar43

    umar43

    Joined:
    Sep 18, 2013
    Posts:
    6
    Hi NiklasBorglund

    I am facing another issue that if I add new keys in CSV and update language with it, that key does not appear in the keys list.
    Help please and thanks.
     
  36. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Just sent you an email about that.

    The update method only updates keys that already exist. You'll have to create the new keys in the root editor first.
     
  37. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Smart Localization 2.1 will have some new features. An updated GUI amongst other things :)

    Here's a little sneak peek of how it's going to look compared to the old version.

    smartloc_gui_update.png
     
  38. dorpeleg

    dorpeleg

    Joined:
    Aug 20, 2011
    Posts:
    250
    looks good!
    ETA?
     
  39. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    We'll do some more testing tomorrow. If everything works the way it should, we'll push it to the store. The asset store usually takes a week to approve updates as well.
     
  40. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    I've submitted it to the store now. It'll probably be up in about a week.

    Here's the changelist for 2.1:

    Version 2.1
    -------------------
    * Completely Remodeled GUI
    * Resizeable column widths in translation and root editing
    * The TranslationWindow is now available in play mode.
    * Added different sorting types in translation window(KEY, VALUE, TYPE)
    * Added the possibility to search by value.
    * Removed the usage of XMLSerializer to make Smart Localization work with all iOS stripping levels.
    * Fixed WP8/Win8 Serialization issue at.
    * Added button to convert \n to line breaks in editor windows.
    * Added more informative error handling with the Microsoft Translator
    * Fixed bug with Microsoft Translation Access Token Expiration
    * Fixed issue with multiple LanguageManagers in scene when used in editor.
     
  41. NiklasBorglund

    NiklasBorglund

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

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    v.2.1002 is out!

    Changelog:
    -------------------

    • Fixed GUI issue when pressing "Copy Root" button
    • Fixed GUI issue when textfield remained in focus for too long.
     
  43. NigmaLab

    NigmaLab

    Joined:
    Aug 30, 2014
    Posts:
    7
    I'm currently testing out beta uploads to the PlayStore, and there seems to be a problem with apk language detection.
    My app currently supports spanish, german and english, but the appstore detects some strange things. It shows: default, spanish (es), Hebrew (iw) and Hebrew (iw) once again.
    I've also tried to add french for testing purpuses but when I upload the new apk, the PlayStore doesn't even notice a new language.

    Any ideas?
    Thanks!
     
  44. NigmaLab

    NigmaLab

    Joined:
    Aug 30, 2014
    Posts:
    7
  45. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Yeah, I did some googling and I found the same thing. We want it to work with any other plugin though.

    We'll look into it and see what we can do :)
     
  46. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    New version submitted to the store. Will hopefully be up in a couple of days.

    Changelog Version 2.1003
    ------------------


    • Fixed duplicate key error when having the same type
    • Updated SmartCultureInfo to contain IsRightToLeft boolean
    • Added a version number in SmartCultureInfoCollection to enable automatic updates to the all cultures file.
     
  47. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    Thank you very much Niklas!! Your asset is incredible useful, can't believe you give it away for free!
    Luckily you give us some scripts for NGUI support, which are working great! Do you think it is possible to support NGUI Texture (UITexture) in the same way?? This would make the ngui support even more complete...
     
  48. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    This was a simple one! Here comes the NGUITexture support :

    Code (CSharp):
    1. // SL_NGUITexture.cs
    2. //
    3. // Copyright (c) 2013-2014 Niklas Borglund, Jakob Hillerström
    4. //
    5.  
    6. #define SMART_LOC_NGUI //<--- UNCOMMENT THIS FOR NGUI CLASSES
    7.  
    8. #if SMART_LOC_NGUI
    9. using UnityEngine;
    10. using System.Collections;
    11. using SmartLocalization;
    12.  
    13. public class SL_NGUITexture : MonoBehaviour
    14. {
    15.     public string localizedKey = "INSERT_KEY_HERE";
    16.     UITexture uiTexture;
    17.  
    18.     void Awake()
    19.     {
    20.         uiTexture = GetComponent<UITexture>();
    21.     }
    22.  
    23.     void Start ()
    24.     {
    25.         //Subscribe to the change language event
    26.         LanguageManager thisLanguageManager = LanguageManager.Instance;
    27.         thisLanguageManager.OnChangeLanguage += OnChangeLanguage;
    28.  
    29.         OnChangeLanguage(thisLanguageManager);
    30.     }
    31.  
    32.     void OnDestroy()
    33.     {
    34.         if(LanguageManager.HasInstance)
    35.             LanguageManager.Instance.OnChangeLanguage -= OnChangeLanguage;
    36.     }
    37.  
    38.     void OnChangeLanguage(LanguageManager thisLanguageManager)
    39.     {
    40.         uiTexture.mainTexture = LanguageManager.Instance.GetTexture(localizedKey);
    41.     }  
    42. }
    43. #endif
     
    Last edited: Oct 15, 2014
  49. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Wow! Thanks! :) Is it okay if we add this class to the package in a future release?

    I'll create the editor script for this as well before we upload it.

    NOTE: Just in case if anyone didn't notice, there's an editor script for each of the NGUI classes that's in the package as well. They are in the Editor folder and are named like the runtimescript + "Inspector".
    To use them, just uncomment the "//<--- UNCOMMENT THIS FOR NGUI CLASSES" at the top of the file.
     
  50. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    Sure, it's your code from NGUILabel, all I did was editing some lines... ;)

    o_O I missed these scripts (nearly impossible), thx! Selecting from dropdown-menu is just more comfortable :)

    Many thanks to LudlowFx, too! His playmaker actions are working just fine!
    => https://github.com/LudlowFx/PlayMaker_SmartLocalization