[RELEASED] Smart Localization for Unity3D

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

  1. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    $SmartLocalizationUnityBanner.png
    Our new plugin called Smart Localization 2.0 is released on the asset store!

    • Create support of a new language within the click of a button
    • Works with both Unity Pro and Free
    • Supports Automatic Translations with Microsoft Translator
    • Localize assets with an easy to use drag drop interface
    • Exports language files into .resx file format

    Asset Store Link(v.2.0): https://www.assetstore.unity3d.com/#/content/7543
    Github Link(v.1.2): https://github.com/NiklasBorglund/SmartLocalization

    Video Tutorial
    Web Player Demo
    Web player demo with localized assets
    Support Mail

    Smart Localization 2.0 works with both Unity Pro and Free.
    Localizing your game has never been this easy!
    Supporting multiple languages in games is becoming increasingly popular, and with Smart Localization you can get full support with just a few mouse clicks!

    $smartLocalizationInfoNew.png

    Smart Localization 2.0 automatically creates a new folder structure where you can save all your localization data.It saves the language files in the .resx file format. ResX is commonly used for globalization and localization. A wide variety of software is used to translate .resx files.

    This plugin also supports Automatic Translations with Microsoft Translator.
    All you have to do is to create a Microsoft Translator account and paste in your credentials in the main window and press "Save" and "Authenticate". The translate language window will show a drop down menu of languages to translate from if that specific language is supported. Microsoft Translator gives you 2 million characters to translate each month for free.
    Guide to get a Microsoft Translator Account

    Documentation.(v.1.2)

    I'll post some of the basics right here.
    Code (csharp):
    1.  
    2. //Returns a text value in the current language for the key
    3. string myKey = LanguageManager.Instance.GetTextValue("MYKEY");
    4.  
    5. //Gets the audio clip for the current language
    6. AudioClip myClip = LanguageManager.Instance.GetAudioClip("MYKEY");
    7.  
    8. //Gets the prefab game object for the current language
    9. GameObject myPrefab = LanguageManager.Instance.GetPrefab("MYKEY");
    10.  
    11. //Gets the texture for the current language
    12. Texture myTexture = LanguageManager.Instance.GetTexture("MYKEY");
    13.  
    14. //To cache the LanguageManager in a variable
    15. LanguageManager languageManager = LanguageManager.Instance;
    16.  
    17. //Get a list of all the available languages
    18. List<SmartCultureInfo> availableLanguages = thisLanguageManager.GetSupportedLanguages();
    19.  
    20. //Get the smart culture info of the system language if it is supported. otherwise it will return null
    21. SmartCultureInfo systemLanguage = thisLanguageManager.GetSupportedSystemLanguage();
    22.  
    23. //Check if a language is supported(string = "en" "sv" "es" etc.)
    24. LanguageManager.Instance.IsLanguageSupported("en");
    25.  
    26. //Change a language(string = "en" "sv" "es" etc., Make sure the language is supported)
    27. LanguageManager.Instance.ChangeLanguage("en");
    28.  
    29. //Set the default language(The language that will be loaded(if it exists) at startup)
    30. //takes SmartCultureInfo or string
    31. LanguageManager.Instance.SetDefaultLanguage("en");
    32. LanguageManager.Instance.SetDefaultLanguage(currentCultureInfo);
    33.  
    This is a video tutorial explaining all the basics and how the system works.


    A video tutorial explaining how the features in version 1.1 works


    Current version 2.0 - Remember to backup your project before updating
    * REMEMBER TO BACK UP YOUR PROJECT BEFORE UPDATING*

    * NOTE: Version 2.0 will create a completely new workspace. It will mostly work as the previous versions, but it got some structural changes.

    Changes
    * Completely reworked the base for increased stability
    * Re-written automatic translator for increased stability
    * CSV Import Export.
    * Moved away from .NET CultureInfo to own class (SmartCultureInfo) to make Smart Localization accessible to more platforms
    * Moved the classes into the SmartLocalization namespace and the SmartLocalization.Editor namespace.
    * Better undo support

    Asset Store Link(v.2.0): https://www.assetstore.unity3d.com/#/content/7543
    Github Link(v.1.2): https://github.com/NiklasBorglund/SmartLocalization
    Last edited: May 13, 2014
  2. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
  3. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Smart Localization 1.1 is submitted to the asset store!

    Version 1.1. will add drag drop interface for prefabs, textures and audio clips which will make it extremely easy to localize assets within your game.
    It will also copy your assets into an automatic folder structure, keeping track of all your localized assets.
    $Skärmavbild 2013-03-21 kl. 10.30.23.png

    Version 1.1 will be available on the Asset Store soon.
  4. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Smart Localization 1.1 is released.
    NEW FEATURE: Drag Drop Interface for localized Prefabs
    NEW FEATURE: Drag Drop Interface for localized Audio Clips
    NEW FEATURE: Drag Drop Interface for localized Textures
    NEW FEATURE: Complete automatic folder structure for localized assets
    NEW FEATURE: Define keys to a type
    NEW FEATURE: Delete languages from editor

    Web player demo with the new features.

    A video tutorial explaining how the new update works.
  5. rocki

    rocki

    Member

    Joined:
    Aug 10, 2012
    Messages:
    1,098
    Great Idea and neat little package.

    Question: I have an excel file with all of the languages, does the package have some sort of batch input so that I don't have to enter every single entry?

    Thanks.
  6. silkroadgame

    silkroadgame

    New Member

    Joined:
    Apr 9, 2013
    Messages:
    102
    Congrats!It's looking good and attracting!
  7. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    No, there's unfortunately no feature like that in the package. What you could do however, is to try and convert your .xls file into a .resx file and compare with how the .resx created in the Smart Localization plugin looks and change accordingly.
    They should not be that different(if any), depending on how your excel file looks.

    Found a tool that might be worth a look http://www.codeproject.com/Articles/19461/RESX-to-XLS-conversion-for-multi-language-support

    Hope that helps!

    Thanks! :)
  8. im

    im

    Member

    Joined:
    Jan 17, 2013
    Messages:
    1,168
    Thanks Niklas!

    Thanks for creating this great asset and for releasing and supporting it for free!

    Best regards,

    me :)

    one little thing

    I was running the demo and when I try to translate from English to French using Microsoft Translation Server I'm intermittently getting

    any ideas what maybe causing it?
    Last edited: Aug 8, 2013
  9. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136

    Thanks! I'm glad you like it :)

    I'm planning on taking some time soon and solve the reported problems. So it can take a few days or so, but I'm on it :)

    Regarding your issue, does it behave like that even when you try to translate to another language? Or is it just French that's giving you problems?
  10. FREEZX

    FREEZX

    Member

    Joined:
    Apr 2, 2013
    Messages:
    32
    Hi and thanks for making this plugin.

    However we seem to be having difficulties making this run on Windows phone 8 as the microsoft's version (.NET 4.0) of the CultureInfo class doesn't have a method called GetCultureInfo. We tried replacing this with new CultureInfo but seem to be getting some weird errors that don't look even remotely connected to the CultureInfo class.
    Could you please assist us with solving this?

    Thanks again.
  11. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Do Windows Phone 8 use some kind of subset of .Net 4.0? If so, can you send me a link to the documentation? Because if i'm looking at the .Net 4.0 docs, they do seem to have a function called GetCultureInfo - http://msdn.microsoft.com/en-us/library/yck8b540(v=vs.100).aspx

    It is a weird error you are getting though, but read elements and load language should not have anything to do with the culture info class. Does the languages created in the Resources folder look alright?
  12. FREEZX

    FREEZX

    Member

    Joined:
    Apr 2, 2013
    Messages:
    32
    This is the documentation page for WP8
    http://msdn.microsoft.com/en-US/lib...stem.globalization.cultureinfo(v=vs.105).aspx
  13. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    You can still use all the functions in the editor, right? It's only when you build to the phone the errors come?

    I'm not in a position to try this on WP8 yet, but you could try and put some special cases (that only turns in effect when you run in wp8 ) in the LanguageManager and only use the List<string> availableLanguages in there. (Like in GetAvailableLanguages() in line 291)

    Some pseudocode:
    Code (csharp):
    1.  
    2. #if !WINDOWS_PHONE_PLATFORM
    3. ....Any code that's related to the CultureInfo class.
    4. #endif
    5.  
    Can't seem to find a define for the windows 8 phone platform, maybe i looked in the wrong places(http://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html)

    EDIT: Found it. It's UNITY_WP8 . (https://docs.unity3d.com/Documentation/Manual/wp8-faq.html)

    The Localization System itself is not dependant on the CultureInfo class. What matters is the language strings in the availableLanguages list. That contains the necessary strings like "en" "es" "fr" "sv" to load the languages.

    Hope that helps. Let me know if it worked. I'll also look into the issue some more.
  14. derkoi

    derkoi

    Member

    Joined:
    Jul 3, 2012
    Messages:
    1,219
    Thanks for the package but I'm also getting this error when I try and auto translate:

    And then sometimes this one after about a minute of waiting:
    Last edited: Sep 23, 2013
  15. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Hi,

    Sorry for the delay. I've fixed some of the bugs on this project now, there's still some things left to be fixed - but overall things should work a lot better now.

    Changes:
    * Sorted the keys in alphabetical order
    * Saved the language file properly with the XMLWriter
    * Several bug fixes
    * Some code refactoring

    However, this version is not uploaded to the Asset Store(yet), it needs some testing. I have uploaded the complete project on github until then under the MIT - License, so feel free to use it.

    https://github.com/NiklasBorglund/SmartLocalization

    To use it in your project, just download the code from github and replace the contents in the SmartLocalization folder with that. Make sure to backup your project before attempting this.

    I will try and find the time within the next few days to test it and upload the latest version to the asset store as well.
    Any questions, comments or feedback can be sent in this thread or DM me on twitter.
    Last edited: Sep 29, 2013
  16. kdimas

    kdimas

    New Member

    Joined:
    Sep 13, 2013
    Messages:
    10
    Hi, thank you for this very nice free asset :)

    I'm developing mini games for Windows Phone 8 and I really need SmartLocalization for my next project.

    I've attached my workaround to be able to use SmartLocalization in WP8, and gladly this tweak worked well! (at least for GetTextValue).

    I hope you can merge my packages with your code so that next version of SmartLocalization in asset store will support Windows Phone 8 out of the box + Playmaker.

    Looking forward to see this asset grab its popularity!

    Attached Files:

  17. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    That's great! Thank you!

    I just added your WP8 changes to the code and submitted all the latest changes to the asset store.(1.3)

    It can take up to a week before it gets accepted though so if you want the latest code right now - you can download it from here: https://github.com/NiklasBorglund/SmartLocalization

    Unfortunately I do not own playmaker, so I can't test your addons for that. Maybe there's a possibility to create a github fork or something for supporting extensions until we can find a more sustainable solution.
  18. kdimas

    kdimas

    New Member

    Joined:
    Sep 13, 2013
    Messages:
    10
    Nice! I think I shall create own repo for SmartLocalization Playmaker Addon
  19. Ogien

    Ogien

    Member

    Joined:
    Nov 21, 2012
    Messages:
    41
    I imported your 1.3 version and I am still getting:

    Error building Player: Exception: Error: type `System.Globalization.CultureTypes` doesn't exist in target framework.

    In the GetSystemLanguage() Method
  20. kdimas

    kdimas

    New Member

    Joined:
    Sep 13, 2013
    Messages:
    10
    Modify LanguageManager.cs, line 538, current code still missing platform definition, current code:
    Code (csharp):
    1. CultureInfo[] cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures);
    2. foreach(CultureInfo info in cultureInfos)
    3. {
    4.     if(info.EnglishName == systemLanguage)
    5.     {
    6.         return info.Name;  
    7.     }
    8. }
    Add platform definition like this:
    Code (csharp):
    1. #if !UNITY_WP8
    2. CultureInfo[] cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures);
    3. foreach(CultureInfo info in cultureInfos)
    4. {
    5.     if(info.EnglishName == systemLanguage)
    6.     {
    7.         return info.Name;  
    8.     }
    9. }
    10. #endif
  21. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136


    Whoops! I'm sorry. I've fixed it now and updated the github repo, let me know if it still doesn't work after this and I'll try and track down the issue.
  22. Ogien

    Ogien

    Member

    Joined:
    Nov 21, 2012
    Messages:
    41
    If you bypass that code then that function can't be used as it returns null. How do you find the system language if you can't use GetSystemLanguage()?
  23. kdimas

    kdimas

    New Member

    Joined:
    Sep 13, 2013
    Messages:
    10
    The idea is implementing manual selection of current system language code in UNITY_WP8,

    "Application.systemLanguage" will return selected language in readable format, e.g. "English", "Indonesian".

    In UNITY_WP8, we must add a dictionary that contains all / major language and map it to certain culture code, such as

    "Engish" => "en",
    "Indonesian" => "id",
    etc

    Haven't got time to try this idea, I suggest @NiklasBorglund to try implementing this workaround :)
  24. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Yeah, in the version I pushed to github yesterday I just returned the default language and logged an error that you can't use that function on windows phone.
    The main reason I used CultureInfo was that the culture english names(and native) were already mapped to their culture code. I'll look into a work around for this, see if I can find a good solution. Don't know if I get time to do that before the weekend though :/

    There's not so many languages that the Application.systemLanguages(http://docs.unity3d.com/Documentation/ScriptReference/SystemLanguage.html) support, so if I can't find another solution - I'll just map every language for WP8 manually.
    Last edited: Oct 16, 2013
  25. im

    im

    Member

    Joined:
    Jan 17, 2013
    Messages:
    1,168
    hi im having lots of problems with the latest release with latest unity. i sent you email with details. any information as to why all the 400 bad request error with microsoft translation service? and all the issues with the ui? thanks in advance!
  26. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Yes, I got your email. I have no idea why you get the 400 bad requests, but I think I know what your UI problem with the translation options is.
    I will look into it as soon as I can find the time.
  27. Ogien

    Ogien

    Member

    Joined:
    Nov 21, 2012
    Messages:
    41
    In Unity Metro "Windows Store" I am also getting the following errors:

    Assets\SmartLocalization\Scripts\LanguageManager.cs(237,16): error CS1061: 'System.Xml.XmlReader' does not contain a definition for 'Close' and no extension method 'Close' accepting a first argument of type 'System.Xml.XmlReader' could be found (are you missing a using directive or an assembly reference?)
    Assets\SmartLocalization\Scripts\LanguageManager.cs(295,32): error CS1061: 'System.Xml.XmlReader' does not contain a definition for 'ReadString' and no extension method 'ReadString' accepting a first argument of type 'System.Xml.XmlReader' could be found (are you missing a using directive or an assembly reference?)
    Assets\SmartLocalization\Scripts\LanguageManager.cs(560,22): error CS0117: 'System.Globalization.CultureInfo' does not contain a definition for 'GetCultureInfo'
  28. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Ok, I haven't tried with the windows store platform anything yet - I'll look into that later.

    But the windows phone 8 fixes i did this morning(on github) works fine now?
  29. im

    im

    Member

    Joined:
    Jan 17, 2013
    Messages:
    1,168
    hi no hurry just letting you know.

    it it strange cause if happens translating like literally the word hello from english to spanish / french which works just fine off their website...

    i also compared your code (request) against the example microsoft gave for api your using... i guess i can use wireshark / put proxy inbetween that records complete request / response to see if there is any difference between their website and the asset...

    i mean you know what your sending but do you know what mono is actually sending or even supporting win32 apis is actually sending ... ;)
  30. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136

    I've tried to reproduce the error 400 request, but I'm failing. Works everytime for me :/ Can you give me any steps to reproduce? What version of unity are you using? I'm using 4.2.2.
  31. Ogien

    Ogien

    Member

    Joined:
    Nov 21, 2012
    Messages:
    41
    I just set the default value of that function to "en" and the user can change the language in Options. Not perfect but it works for now until someone comes up with an alternative.
  32. im

    im

    Member

    Joined:
    Jan 17, 2013
    Messages:
    1,168
    same

    the thing is like the 1st time gui is toast, next time request works after that request fail, exit repeat...

    so perhaps its something that is not being cleanup/init right between requests

    i put debug/log and the url/request looked valid

    i will look at the response when i get a chance to see if they give some details as to what is bad about the request...
  33. Ogien

    Ogien

    Member

    Joined:
    Nov 21, 2012
    Messages:
    41
    I just want to add that even though your changes work in the Unity Player, once you deploy to a Windows Phone the thisLanguageManager.GetTextValue() method always returns null :(
  34. Ogien

    Ogien

    Member

    Joined:
    Nov 21, 2012
    Messages:
    41
    Did anyone manage to get this working on Windows Phone or Metro. Its a really great plugin and its a shame if it does not work on all platforms. I now have to somehow write a wrapper to disable Localization on WP8 and Windows Store, or else I can't update my app.
  35. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Yeah, sorry. Not yet. I looked at it some, and WP8 uses a subset of .NET, which complicates things because they don't use the same classes. I unfortunately don't have any devices or dev-accounts to test on WP8 and I also don't know when I'll have the time to rewrite big parts of the plugin to fix it for these two platforms.
    If anyone feels up to the task, you are more than welcome to create a github fork to fix this.
  36. men7ous

    men7ous

    New Member

    Joined:
    Nov 15, 2012
    Messages:
    1
    Hey, amazing asset NiklasBorglund, thanks for sharing :)
    Last edited: Nov 22, 2013
  37. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Thank you! :)
  38. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    EDIT - Smart Localization is still being updated actively.

    I thought I would write a heads up message to everyone using Smart Localization.

    First of all, thank you for all your feedback and comments! They have been very helpful to me :)

    Unfortunately, the company(Cry Wolf Studios) I released this plugin under will cease to exist within a week or two.( i.e. the company will be liquidated).
    This means that I will remove the plugins from the unity asset store within a week from now.

    However, I do still own both of the plugins that we released - so I have created repositories for both of them on Github and placed the projects under an MIT-license. This basically means that you can download it /fork it/ change it etc. in any way you want as long as the license header is intact.

    Sorry for any inconveniences caused by this.
    Last edited: Sep 16, 2014
  39. derkoi

    derkoi

    Member

    Joined:
    Jul 3, 2012
    Messages:
    1,219
    Thanks for the heads up.

    Couldn't you release them on the Asset Store yourself?
  40. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Well, not the Asset Bundle Creator because it's a pro feature and the unity license I had was tied to the company.
    I could re-release Smart Localization, but since I'm not able to work with my own stuff full time anymore and I recently aquired a new game programming job, I don't think I will be able to give the adequate support that's required for the unity asset store.
    So I thought that Github would be a more suitable platform for me to release my code.
  41. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    I've looked at some alternatives in keeping this project up on the asset store, since there seems to be people that like it. I think I've found a solution.

    I talked to a programmer friend with him taking a joint ownership in the product and keep updating it with new content. That seems to be happening. (EDIT: This happened)
    We'll probably change some things, rework some needed parts of the plugin and submit an update. I don't know when that will be exactly, but stay tuned for more info :)

    Again, sorry for all the back and forth decisions regarding this.
    Last edited: Sep 16, 2014
  42. moscoquera

    moscoquera

    New Member

    Joined:
    Nov 16, 2013
    Messages:
    4
  43. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
  44. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Hi all,

    Just wanted to write that Smart Localization is still in development. As I mentioned before, I teamed up with another developer and we are refactoring the code to make the foundation a bit more stable.

    The new version will also support some new features, like CSV Import/Export.

    We've also been looking at a solution to not use the System.Globalization framework so that it will work on platforms that doesn't fully support it.

    /Niklas
  45. im

    im

    Member

    Joined:
    Jan 17, 2013
    Messages:
    1,168
    hi, happy new year!

    that is great to hear since this is the very best translation solution out there for unity...

    in addition to microsoft translation which is intermittently fickle please consider adding support for google translate service.

    thanks in advance!
  46. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136

    Thank you!

    I'm glad you like it :)

    The reason I chose Microsoft Translator is because they have 2 million free characters per month. Google Translate does not.

    But I'll write it down as a suggested feature, and I'll take a look at it.

    Question to all Smart Localization users and readers of this thread:
    Besides Google Translate and CSV-Support - What features would you like to see added the most?
  47. Yocal

    Yocal

    New Member

    Joined:
    Feb 10, 2014
    Messages:
    6
    To get rid of the rain of warnings :)

    - http://screencast.com/t/pEcLpFh5

    Feature-wise it's just what I've been looking for - but I'd rather pay $5-10 and get something that doesn't throw warnings out of the box :) Once cleaned up, I'd be a happy user!
  48. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Yes, the warnings will be fixed :D They appeared after Unity 4.2 or 3 made some methods I previously used obsolete.
  49. NiklasBorglund

    NiklasBorglund

    Member

    Joined:
    Feb 9, 2012
    Messages:
    136
    Thought I should post a work-in-progress update. With a picture this time :)

    $csvProgress.png
  50. Axlflame

    Axlflame

    New Member

    Joined:
    Nov 12, 2013
    Messages:
    1
    Hi,

    I'm sorry if this is a stupid question, but I'm new to Unity and just started using Smart Localization on a project. I noticed that Smart Localization creates its own folder for scripts, but I already had one folder for my other scripts. My problem is that I can't access the LanguageManager from these other scripts.

    Do they (my scripts and the smart localization ones) have to be on the same folder or is MonoDevelop screwing with me?

    Thanks in advance!