Search Unity

[RELEASED] Smart Localization for Unity3D

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

  1. DiebeImDunkeln

    DiebeImDunkeln

    Joined:
    Nov 17, 2014
    Posts:
    8
    I'm using the free version and have the problem, if i switch between 2 scenes which both use the localization I get this error:


    IOException: Sharing violation on path E:\UnityProjekte\DiebeImDunkeln\Assets\SmartLocalizationWorkspace\AutoGenerated\Resources\AvailableCultures.xml
    System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/FileStream.cs:320)
    System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
    (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    System.Xml.XmlTextWriter..ctor (System.String filename, System.Text.Encoding encoding)
    SmartLocalization.Editor.SmartCultureInfoEx.Serialize (SmartLocalization.SmartCultureInfoCollection info, System.String fullPath)
    SmartLocalization.Editor.LanguageHandlerEditor.CheckAndSaveAvailableLanguages (SmartLocalization.SmartCultureInfoCollection allCultures)
    SmartLocalization.Editor.AndroidStorePresenceGenerator.CheckStorePresence ()
    SmartLocalization.Editor.AndroidStorePresenceGenerator.get_HasStorePresence ()
    SmartLocalization.Editor.AndroidStorePresenceGenerator.GeneratePresence ()
    SmartLocalization.Editor.AndroidStorePresenceGenerator.OnPostProcessScene ()

    Any idea what I can do to avoid it?

    Thanks in advance
    Frank
     
  2. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi, can you try and reimport the plugin from scratch? I'll do some investigating, but we have removed everything we added in SmartLocalization to the AudioSource component. So it should not be there.

    Please let us know if anyone else experience this.
     
  3. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    hmm, Try and untoggle the "Generate Android Store Presence" Toggle in the Smart Localization window. We'll investigate and see if we can reproduce.

    Hope that helps,
    Niklas
     
  4. DiebeImDunkeln

    DiebeImDunkeln

    Joined:
    Nov 17, 2014
    Posts:
    8
    I untoggled the "Generate Store Presence" for both and now the error is gone.
    Thanks
     
  5. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    Hey NiklasBorglund,
    first of all thanks for this GREAT tool, i just started to use it, and yet only the free version but i have a question....

    i have a bunch of keys like
    Player.Profession.Carpenter
    Player.Profession.Blacksmith
    etc
    is it possible to get all keys containing "Player.Profession" so i would get "Carpenter, "Blacksmith".I don't think so but i think it would be very nice so maybe you can integrate it....

    I think i read that the pro version comes with source code access so it should be easy for me to integrate it on my own when i purchase pro right?
     
  6. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That would be a very nice feature, I agree! :) I've added it to our list of feature requests.

    Yes, The pro version comes with the full source and other utility convenience methods & features :)
     
    CxydaIO likes this.
  7. zuric

    zuric

    Joined:
    May 22, 2014
    Posts:
    10
    Wrote a blog post about the plural support in SmartLocalization PRO if anyone is interested :)
    It can be found here.
     
    iqbal_mineral likes this.
  8. rafaellop

    rafaellop

    Joined:
    Feb 4, 2015
    Posts:
    26
    Hi, I have some troubles using the Smart Localizer tab. Sometimes I need to correct a string and what I do is that I click the TRANSLATE button to open a language. Then I enter a part of the string that I want to change in the SEARCH filed and I switch the target to VALUE. My string is correctly found but if I try to edit it the troubles start. In the case that I need to change a word in the found string I select it and press the delete key to remove the old one and enter a new translation. At this point sometime the whole row is deleted from the view. I have to close the view and remember not to save and reopen it and try the same things until I succeed with the change. This is a bit annoying. I'm on Unity 4 (latest).

    I've also got a feature idea. I use the LocalizedText script to have my uGUI translated in runtime. It would be great that the inspector would show not only the key but also its translations and allow to copy (use) a selected translation on the text component in the same gameobject.

    Do you maybe know if Unity4 handles right-to-left languages correctly and the same about Smart Localizer? I can see a sample string in my game if paste it to the text component, but I'd like to be sure that if I ask for translation it won't be a waste of time :)

    Besides congratulations on a great product! :)


    Cheers,
    Rafal
     
  9. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    hey, short question ... i made a empty GameObject called "LanguageManager" and attached the LanguageManager script to it, setup the default language and run the game... it works! But every now and then the "LanguageManager" Go gets instanciated with another default language ... after some time it happens that i end up with more and more LanguageManager GOs ...
    Why is this happening?
    Is maybe the LanguageManager Instanciating itself if it doesn't find the instance, and when the game crashes the new instance remains and does not get deleted?
     
    Last edited: Apr 22, 2015
  10. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    First of all, so sorry for the late answers. I really thought that I had email notifications on this thread (and that I had read the latest one).

    Are you doing stuff in OnDestroy() or similar? There's a check that you can do - LanguageManager.HasInstance - which returns if there's a singleton instance available. You can use this variable in places that the languagemanager might not exist anymore.

    Yes, you are so right. Good catch - we have filed it as a bug. Thanks :)

    Feature Request added :) I added it as "Being able to see/toggle between translations in the editor when not running the game". Does that accurately describe it?

    No, Unity does not handle RTL - text out of the box, and neither does Smart Localization. You need a library that does right-to-left conversion. And in languages like arabic, you need to handle issues like wordwrapping prior to that conversion to make it look correct.
     
  11. rafaellop

    rafaellop

    Joined:
    Feb 4, 2015
    Posts:
    26
    Hi, thanks for adding the feature to your todo. Great!

    Regarding RTL, I suppose Hindi is also RTL because if I paste a UTF-8 Hindi text taken from e.g. google translate there's nothing except few spaces in the inspector. The same in the Smart Localizer and even if I import a sample Hindy text from a CSV file it is still empty (filled with few spaces). Do you think there's a way to handle Hindi? I've checked the asset store and there's support only for Arabic/Hebrew and because I cannot see Hindi at all (though Arabic pasted is OK), I suppose this asset for Arabic/Hebrew won't help with Hindi. Any ideas guys?
     
  12. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hmm, that it's not showing at all sounds like a font issue - not an RTL issue. What RTL algorithm solves is to calculate how the text should be rendered and converts it from a logical to how it's supposed to be rendered.
    Usually it's this algorithm that's implemented to solve this - http://unicode.org/reports/tr9/

    Although, I would be surprised if there weren't any open source libraries that you could implement that has this bidi algorithm.
     
  13. rafaellop

    rafaellop

    Joined:
    Feb 4, 2015
    Posts:
    26
    It wasn't font issue, I think. I've read that standard Arial font delivered with Unity should display hindi. Nevertheless, it's not a problem of your plugin, so forget it :)

    I'e got another question, can I control in Smart Localizer the languages that Google Play Store finds in the APK I submit there? I've got almost ten languages in Smart Localizer but Google finds two. What can I do?

    Cheers,
    Rafal
     
  14. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That's what our "Generate Store Presence" is supposed to do. But that feature is still in beta and might have some issues, but you can try checking the box "Generate Google Play Store Presence" in the main localization window.
     
  15. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Hey Niklas,

    Is there a way to check what is generated when doing this? If it fails to include all languages, is there a way to do this manually for Android and iOS?
     
  16. rafaellop

    rafaellop

    Joined:
    Feb 4, 2015
    Posts:
    26
    larku, thanks :) It's exactly what I wanted to ask :) Please let us know Niklas how to eventually handle this by hand.
     
  17. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    Hey Niklas, thanks for your answer, but no .. i don't do anything with OnDestroy... but i now found the issue .. it seems that saving and loading causes the duplication of the LanguageManager GO o.0 .. its very strange .. each time i load the scene a LanguageManager GO appears, if there already was one i get another one and so on o.0

    Am i doing something wrong here ? I'm using unity 5.01
     
  18. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    For Android, folders are added with a strings.xml file for each language that will be included automatically in your apk. You can find the folders in Plugins->Android->res->

    For IOS, it adds the locales into the info.plist file under a property called "CFBundleLocalizations".

    Are you using the LanguageManager in some editor scripts (i.e. when not pressing play?) - that could create an issue - since the languagemanager is created for runtime only.
    But still, I remember fixing an issue similar to this a while ago, We'll investigate and see what we can find.
     
    zuric likes this.
  19. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    hmm yes i do, with this hint i was able find the error and it's indeed the editor script which creates a LanguageManager GO after OnValidate() got executed.

    it's not a big problem since everything is working fine, thanks for your help :)

    Cxyda
     
  20. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    That's great. I'm glad it worked out :)
     
  21. rafaellop

    rafaellop

    Joined:
    Feb 4, 2015
    Posts:
    26
    Hi Niklas, so these autogenerated store files are only to inform app stores about supported languages or is there another use for them? I suppose we could localize the game name in these, but what else can we do with this? Could you please describe in few words?

    A bug report: if I paste a multiline text from XLS file (copying without entering the cell contents) there are invisible line feeds copied along and they become visible in gameplay or after close/open of the language tab.

    Cheers,
    Rafal
     
  22. resakosix

    resakosix

    Joined:
    Sep 26, 2012
    Posts:
    5
    Hello Niklas.

    I've used smartlocalization on iOS and Android without any problem (text only, two languages). Now I'm deploying to webgl and the system returns a null string every time (the same code that works perfectly on PC standalone, unity webplayer and mobile).
    Is there any known issue with webgl?

    Regards,
    Edu
     
  23. LinderBoss

    LinderBoss

    Joined:
    May 1, 2014
    Posts:
    8
    Hello Niklas,

    Is Smart Localizations compatible with the Windows Store 8.1 target?

    It seams to work well with Android & WP 8, but my test game throws an error after I import the package, build for Windows Store and compile the thing within Visual Studio. The project was working before adding Smart Localization into the mix.

    Here is the error:

    Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'SmartLocalization_Runtime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
    em Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
    em Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
    em Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
    em Unity.Serialization.Weaver.MethodEmitterBase.WillUnitySerialize(FieldDefinition fieldDefinition)
    em Unity.Serialization.Weaver.SerializeMethodEmitter.ShouldProcess(FieldDefinition fieldDefinition)
    em System.Linq.Enumerable.<>c__DisplayClassf`1.<CombinePredicates>b__e(TSource x)
    em System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
    em Unity.Serialization.Weaver.MethodEmitterBase.EmitMethodBody()
    em Unity.Serialization.Weaver.SerializationWeaver.AddSerializeMethod()
    em Unity.Serialization.Weaver.SerializationWeaver.Weave()
    em usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition)
    em usw.Weaver.Weave()
    em usw.Program.RunProgram(ConversionOptions options)
    em usw.Program.Main(String[] args)

    My current software: Unity 5.0.1p4 + Visual Studio Update 4 + Windows 8.1.

    Thanks,
    LinderBoss
     
  24. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Thanks for the bug report :)

    Yes, the autogenerated files are mostly used for localization when creating an application for android (i.e. not in unity). You use something called strings.xml files to add language values and resources.

    You can read more about it here: http://developer.android.com/guide/topics/resources/localization.html

    Thank you for the report and no there's no known issue with WebGL until just now :) tbh, we haven't looked at webgl much, but we will have a look asap and try and resolve your issue.

    Thanks! We'll have a look asap and try to solve it. It should be compatible with windows store.
     
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,084
    Hello, I am enjoying Smart Localization. Great asset!

    I have a question. I wanted to use Smart Localization to provide different instructions for different control setups on different platforms. For example on Mobile: touch to jump, pinch to zoom, two finger drag to pan, on Desktop. click to jump, scroll wheel to zoom, arrow keys to pan. I thought I would be able to do this by adding more languages, however the list of languages seems hardcoded and the language keys seem standardized to match online store. How would you recommend to do this?

    Thanks.
     
  26. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Hi, I'm glad you like the plugin :)

    I think that the simplest solution would be to create different keys for different control methods.
    for example if you have keys and values that look like this:

    tutorial.jump.mobile = touch to jump
    tutorial.zoom.mobile = pinch to zoom
    tutorial.jump.desktop = click to jump
    tutorial.zoom.desktop = scroll wheel to zoom

    And then at runtime you create a script to tell you whether it's mobile or not.
    Code (csharp):
    1.  
    2. string myPlatform = "mobile";
    3. string myTutorialString = "tutorial.jump." + myPlatform;
    4.  
    That's how I would solve it.

    Hope that helps :)

    To answer your other question, the languages are not hard coded. You can create additional ones through an editor window in Smart Localization PRO.
     
  27. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,084
    Thanks for the fast reply Nicklas, I will try that.
     
  28. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Smart Localization 2.2.1 is released! (for both FREE & PRO versions)

    Changelog:
    • Fixed some incompatibility issues with Unity 5
    • Fixed IO sharing violation on google store presence
    • Improved key/value searching in the editor windows
    • Fixed issue where you couldn't add zh-CHT to your project
    • Minor bug fixes
     
  29. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    We added a method in 2.2.1 for this.
    It's in LanguageManager.GetKeysWithinCategory(string category) for runtime scripts and LanguageHandlerEditor.GetKeysWithinCategory(string category) for editor scripts.

    Hope this helps :)
     
  30. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    AWESOME !!! Thanks Niklas :)
     
  31. phasiclabs

    phasiclabs

    Joined:
    Nov 13, 2013
    Posts:
    126
    Hi there,
    I have a question about SmartLocalization - is it possible to plug-in extra language content as part of a DLC pack (ie. have multiple resx files that can be loaded at the same time)?

    If it is possible, is it also possible to author different packs of text using the SmartLocalization Window? It looks like you can only create one pack of text per project.

    Thanks,
    Paul
     
  32. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    There are two ways to add extra content at runtime by using methods in the LanguageManager.

    One is called:

    Code (csharp):
    1.  
    2. void ChangeLanguageWithData(string languageDataInResX, string languageCode);
    3.  
    And will work just as if you loaded it with built in resources, but the difference is that you send in the .resx data yourself. (The same method is used internally)

    The other one is called:
    Code (csharp):
    1.  
    2. bool AppendLanguageWithTextData(string languageDataInResX);
    3.  

    That will load and try to append data to the currently loaded language. If there's a newer value in the "new" .resx data, then that will be used instead.

    These methods supports only strings at the moment.

    Atm, you can only edit one pack of text with the Smart Localization Window, but I've added it as a feature request now :)
     
  33. DeepShader

    DeepShader

    Joined:
    May 29, 2009
    Posts:
    682
    The Pro version supports plural? How? There's no screenshot - nothing on the Asset Store shows it. Is it possible to see it here, before I buy it? :)
     
  34. zuric

    zuric

    Joined:
    May 22, 2014
    Posts:
    10
  35. DeepShader

    DeepShader

    Joined:
    May 29, 2009
    Posts:
    682
    Good idea - thank you :)

    Why you don't support Google Translator? It's much easier to use a translator without creating an extra account :p
     
  36. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    Simple answer is that Microsoft Translator is free to use below 2M characters per/month using their official API.
    I we want to use the official API of Google Translate, you'll have to create an account as well - and the cost is 20 dollars/ per 1M characters of text.
     
  37. DeepShader

    DeepShader

    Joined:
    May 29, 2009
    Posts:
    682
    Oh ok, thank you :)
     
  38. phasiclabs

    phasiclabs

    Joined:
    Nov 13, 2013
    Posts:
    126
    Great, thank you - I'll take a look at those functions - it sounds like they might be just what I need.
    As for the feature request - do you have a rough idea of how long that would take to implement (and get released)?
    I guess I can make dummy projects for now just to create the assets though.
     
  39. LinderBoss

    LinderBoss

    Joined:
    May 1, 2014
    Posts:
    8
    Hi Niklas,

    Any update about the SerializationWeaver issue with the Windows Store player?

    Thanks!
     
  40. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    It's quite the extensive change to the system, so I'm not sure - but it would enable a lot of potential & cool features :) Jakob and I will discuss it some more and decide where to to take it.

    We haven't pinpointed the root of the problem just yet, but we'll keep you posted. Sorry for the delay.
     
  41. rafaellop

    rafaellop

    Joined:
    Feb 4, 2015
    Posts:
    26
    Niklas, is there a way to get a country code in the ISO format from your Smart Localization plugin? I can get system language code, but cannot see the country code. Could you please advice?
     
  42. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    I'm not sure I follow. The languageCode variable in the SmartCultureInfo class is in ISO-639 format. Or do you want it in another format?
    Or are you talking about the region code? In that case, no - there's no such variable in the SmartLoc system. Maybe you could regex remove everything after the first dash - that would probably give you the region code.

    Hope that helps
     
  43. rafaellop

    rafaellop

    Joined:
    Feb 4, 2015
    Posts:
    26
    Hi, I'm talking about ISO 3166 Country Code. I can get the Languge Code from culture info, but it's no way to guess the country from it.
     
  44. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    You could try and use the CultureInfo class in the System.Globalization namespace in .NET. However, that might give you some trouble if you are building to WP8 or Win8, since there's some compatibility issues there.
     
  45. hrjunker

    hrjunker

    Joined:
    Nov 15, 2011
    Posts:
    26
    Hi I am using smartlocalization for a project and wanted an external translator to translate the text for the project, so though your csv import would be awesome. But I'm experiencing it crashing everytime I try to import a csv file. Actually it crashes before I can even press "open" in the file selection menu. I am currently running Unity 4.6.5f1 on a Mac. The crash does not happen when using Unity 5, so it's clearly related to Unity 4. Hope this is something that can be fixed on your side.

    Steps to reproduce: Create a new project, import Smart Localization (pro or free), create root file and language. Export the language to csv. press update language and as soon as you select the exported csv file (or any other csv file) it crashes.

    I have attached the crashlog I get when Unity crashes
     

    Attached Files:

  46. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    This doesn't solve your direct issue (sorry). But I've done this but I used the .resx files since then there is no importing/exporting required - just copy over the files and done.

    I got my translators to use SimpleResxEditor: http://simpleresxeditor.blogspot.com.au/

    Worked perfectly for 8 different translators for 8 languages.
     
  47. hrjunker

    hrjunker

    Joined:
    Nov 15, 2011
    Posts:
    26
    Thanks @iarku for the tip. And yes it doesn't solve the issue in the plugin. Currently my solution is to have a project in Unity 5 with the same root file setup as the original project, import the csv files here, and copy the generated resx files into the original Unity 4 project. :)

    But I would think it is in the interest of the authors to fix the issue, unless they are only aiming to support Unity 5
     
  48. NiklasBorglund

    NiklasBorglund

    Joined:
    Feb 9, 2012
    Posts:
    262
    This is not an issue with Smart Localization. It's an issue with Unity 4.6 and OSX Yosemite(10.10), it crashes by only selecting a .csv file with the EditorUtility.OpenFilePanel() - I have tried with a completely empty project and it crashes every time.

    I filed a bug a while ago, never got an answer. But it seems like they've fixed it in Unity5.
    Link to bug report: http://fogbugz.unity3d.com/default.asp?670589_n8oup9v8la6trekg

    A simple workaround to make it work in 4.6 is to rename your ".csv" files to ".txt"

    Hope that helps,
    Niklas
     
  49. gromerr

    gromerr

    Joined:
    May 21, 2014
    Posts:
    15
    Hello, I have problem when I change game level language stop working.
    For testing I have modified your script LoadAllLanguages add Awake function and button to switch level
    Code (csharp):
    1.  
    2. /
    3. //
    4. //  LoadAllLanguages.cs
    5. //
    6. //
    7. // Written by Niklas Borglund and Jakob Hillerström
    8. //
    9.  
    10. namespace SmartLocalization
    11. {
    12. using UnityEngine;
    13. using System.Collections.Generic;
    14.  
    15. public class LoadAllLanguages : MonoBehaviour
    16. {
    17.     public static LoadAllLanguages lang;
    18.    
    19.     private Dictionary<string,string> currentLanguageValues;
    20.     private List<SmartCultureInfo> availableLanguages;
    21.     private LanguageManager languageManager;
    22.     private Vector2 valuesScrollPosition = Vector2.zero;
    23.     private Vector2 languagesScrollPosition = Vector2.zero;
    24.  
    25.  
    26.     void Awake(){
    27.            
    28.         HoldInEveryScene();
    29.     }
    30.    
    31.     private void HoldInEveryScene(){
    32.            
    33.         if( lang == null ){
    34.             DontDestroyOnLoad( gameObject );
    35.             lang = this;
    36.         }else if( lang != this){
    37.             Destroy( gameObject );
    38.         }
    39.     }
    40.  
    41.     void Start ()
    42.     {
    43.         languageManager = LanguageManager.Instance;
    44.        
    45.         SmartCultureInfo systemLanguage = languageManager.GetSupportedSystemLanguage();
    46.         if(systemLanguage != null)
    47.         {
    48.             languageManager.ChangeLanguage(systemLanguage);  
    49.         }
    50.        
    51.         if(languageManager.NumberOfSupportedLanguages > 0)
    52.         {
    53.             currentLanguageValues = languageManager.RawTextDatabase;
    54.             availableLanguages = languageManager.GetSupportedLanguages();
    55.         }
    56.         else
    57.         {
    58.             Debug.LogError("No languages are created!, Open the Smart Localization plugin at Window->Smart Localization and create your language!");
    59.         }
    60.  
    61.         LanguageManager.Instance.OnChangeLanguage += OnLanguageChanged;
    62.     }
    63.  
    64.     void OnDestroy()
    65.     {
    66.         if(LanguageManager.HasInstance)
    67.         {
    68.             LanguageManager.Instance.OnChangeLanguage -= OnLanguageChanged;
    69.         }
    70.     }
    71.  
    72.     void OnLanguageChanged(LanguageManager languageManager)
    73.     {
    74.         currentLanguageValues = languageManager.RawTextDatabase;
    75.     }
    76.    
    77.     void OnGUI()
    78.     {
    79.         if(languageManager.NumberOfSupportedLanguages > 0)
    80.         {
    81.             if(languageManager.CurrentlyLoadedCulture != null)
    82.             {
    83.                 GUILayout.Label("Current Language:" + languageManager.CurrentlyLoadedCulture.ToString());
    84.             }
    85.            
    86.             GUILayout.BeginHorizontal();
    87.             GUILayout.Label("Keys:", GUILayout.Width(460));
    88.             GUILayout.Label("Values:", GUILayout.Width(460));
    89.             GUILayout.EndHorizontal();
    90.            
    91.             valuesScrollPosition = GUILayout.BeginScrollView(valuesScrollPosition);
    92.             foreach(KeyValuePair<string,string> languageValue in currentLanguageValues)
    93.             {
    94.                 GUILayout.BeginHorizontal();
    95.                 GUILayout.Label(languageValue.Key, GUILayout.Width(460));
    96.                 GUILayout.Label(languageValue.Value, GUILayout.Width(460));
    97.                 GUILayout.EndHorizontal();
    98.             }
    99.             GUILayout.EndScrollView();
    100.            
    101.             languagesScrollPosition = GUILayout.BeginScrollView (languagesScrollPosition);
    102.             foreach(SmartCultureInfo language in availableLanguages)
    103.             {
    104.                 if(GUILayout.Button(language.nativeName, GUILayout.Width(960)))
    105.                 {
    106.                     languageManager.ChangeLanguage(language);
    107.                 }
    108.             }
    109.  
    110.                 if(GUILayout.Button("Change level", GUILayout.Width(960)))
    111.                 {
    112.                     if( Application.loadedLevel == 0 ){
    113.                         Application.LoadLevel(1);
    114.                     }else{
    115.                         Application.LoadLevel(0);
    116.                     }
    117.  
    118.                 }
    119.             GUILayout.EndScrollView();
    120.         }
    121.     }
    122. }
    123. }//namespace SmartLocalization
    124.  
     
  50. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I think you'll need to call LanguageManager.SetDontDestroyOnLoad (); at some point.
     
    iqbal_mineral and NiklasBorglund like this.