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

Localization package. Save yourself a lot of time in the future, enable localization!

Discussion in 'Assets and Asset Store' started by MikeHergaarden, Jul 1, 2011.

  1. mr_fox

    mr_fox

    Joined:
    Nov 28, 2012
    Posts:
    3
  2. Deleted User

    Deleted User

    Guest

    Hi, I've been using this package for a long time now, and it's great! However, I've had to make one change: as I read the code, it seems that the last-used language as saved in the PlayerPrefs always overrides the useSystemLanguageAsDefault option, and I always want to use the system language, so I just comment out the references to the PlayerPrefs. But maybe an alwaysUseSystemLanguage option would be better for this case?
     
  3. Parallaxe

    Parallaxe

    Joined:
    Apr 9, 2013
    Posts:
    118
    Hi there

    I can't figure out how this works with DaikonForge labels. I have seen a script specifically for NGUI, but DaikonForge does not seem to be supported?

    Update:
    I had a look at the NGUI script and I think I can write a new script that works with DaikonForge. So this issue is somehow solved.

    However, I ran into the same issue as mr_fox. Trying to to "Update translations" with my gDoc spreadsheet I got the following error:

    I'm not sure if this is the common way to solve this problem, but I found a workaround: I had a look at the spreadsheets from mr_fox and Mike. And there I noticed that the only difference from theirs to my spreadsheet was that they had two sheets within their spreadsheet (Sheet1 and Sheet2). After I have added a second sheet (and added some languages there, because otherwise I got another error) it worked. Sounds weird but it helped to solve the error for me (-;

    Update 2:
    I managed to rewrite the NGUI script. It now works for DaikonForge as well (Labels and Buttons). If somebody is interested in the small script, just drop me a note.
     
    Last edited: Apr 28, 2014
  4. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Thanks! I've fixed this error and also updated the documentation.
    The fix has been submitted to the app store and should be live ASAP.
    A very easy workaround for now is to simply add another (empty) sheet to your spreadsheet.
    Sorry for the trouble.

    Technicat: cool to her you're STILL using it :).
    I don't see use for always enforcing system language as the people in the netherlands here (myself included) hate dutch localizations and prefer english in games etc. So thats why i made it to auto detect only once (and save that) and from that point on allow user overrides.
    However I got this request a lot so I'll indeed need to add this option. If i had a few more minutes I would have done it right now but I gotta run!
     
  5. Deleted User

    Deleted User

    Guest

    So I finally got around to localizing my first game...so after setting my game up for 16 languages, everything looked good, in the editor, in the spreadsheet, when I exported to .xls..all looked great, updated languages..even the individual .xml resource files looked good...so when I published my game to my phone.. AR, JA, KO, ZH..all do not show up...so I added folders for each and put your font.ttf (from example scene) in the folder for each language ( FR ) / font.ttf ...build, Run..same thing..before I just dump those languages, can you give me some insight..I am using this code at the bottom, and can see the debug when it changes..

    Code (csharp):
    1.     void ChangedLanguage(LanguageCode code)
    2.     {
    3.         //Debug.Log("DEMO We switched to: " + code);
    4.         skin.font = (Font)Language.GetAsset("font");
    5.         //Debug.Log("DEMO Font: " + skin.font);
    6.     }
    How I am using it:

    Code (csharp):
    1.     public void OnGUI(){
    2.  
    3.         if (skin)
    4.         {
    5.             GUI.skin = skin;
    6.             GUI.skin.button.fontSize = (int)(FontSizeMult * MyScreen.y);
    7.             GUI.skin.label.fontSize = (int)(FontSizeMult * MyScreen.y);
    8.         }
    9.         if (GUI.Button(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 150, Screen.width / buttonXSize, Screen.height / buttonYSize), Language.Get("MAIN_MENU0")))
    10.         {
    11.             Application.LoadLevel("Level0");
    12.  
    13.         }
    14.  
    any help would be appreciated!!

    Thanks.

    Patrick
     
  6. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Just to be sure, try a: Debug.Log( Language.Get("MAIN_MENU0") );

    However, I'm pretty sure that the font file you're using does not support these "exotic" characters.
    Give a few other fonts a ty or try to make sure you copy the same font as used in the demo (and verify that that works for JA/ZH).
     
  7. Deleted User

    Deleted User

    Guest

    It is just strange that I can see them in editor/web(my Google drive) / Open Office Spreadsheet..All have the right character font (at lease it looks like Chinese?? :) Take a look here..so that font is somewhere on my computer, over writing the the unity editor font? here is what I did :

    Code (csharp):
    1.     void ChangedLanguage(LanguageCode code)
    2.     {
    3.         //Debug.Log("DEMO We switched to: " + code);
    4.  
    5.         if (code == LanguageCode.AR)
    6.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    7.  
    8.         if (code == LanguageCode.JA)
    9.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    10.  
    11.         if (code == LanguageCode.KO)
    12.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    13.  
    14.         if (code == LanguageCode.ZH)
    15.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    16.  
    17.         GUI.skin.button.fontSize = (int)(FontSizeMult * MyScreen.y);
    18.         GUI.skin.label.fontSize = (int)(FontSizeMult * MyScreen.y);
    19.  
    20.         Debug.Log("Font: " + GUI.skin.font);
    21.         Debug.Log("Font Size: " + GUI.skin.button.fontSize);
    22.  
    23.     }
    I also searched and found Free Windows Fonts ISO TTF And found Them all!!-->: Here

    and another tip!!! : Have 2 Working copies of your spreadsheet 1) BETA: Has the Translate Formula 2) Alpha: Exported from BETA (as .ODT or .XLS), then Upload/Re-imported into New STATIC Web Shared spreadsheet with NO Formulas.
    That is the ONLY way I was able to update in unity in Seconds, without the [Loading...] Response!!!....no look up..no load time!!

    Patrick
     
  8. Deleted User

    Deleted User

    Guest

    How do I know my languages are actually working, The buttons on my game work, switches languages, I checked the "Try to use System Language"...Is there something more I need to do?

    My Google developer console wants something else...

    re..

    Translate strings in your APK into Russian and French (I did!!)
    You translated the store listing into French but not the APK.(I did!!)

    is it because they want me to use the paid service, or that I am missing a strings.xml file in my plugins directory??

    the game is on my tagline..

    p-
     
  9. klicktock

    klicktock

    Joined:
    Jun 9, 2011
    Posts:
    7
    Hey Mike, I think your HTML converter is busted? Instead of ' (apostrophe) I'm seeing &#39.

    Also, carriage returns aren't being carried through to the XML. So multi-line entries are all appearing in one line.
     
  10. appxplore-tech

    appxplore-tech

    Joined:
    Jul 4, 2012
    Posts:
    62
    Hi there,

    I had bought your plugins and tried just now. I found that if I use Google Translate inside the gDocs SpreadSheet, I can only get "loading..." when i baked into my unity projects in stead of the word i had translated.
    Is there anything I'm missing or I should set in my Unity Project?

    Thank you.
     
  11. andrewow

    andrewow

    Joined:
    Dec 2, 2013
    Posts:
    13
    Looks like a great tool! Two quick questions.

    1) Does the package help you translate 3d text? I have some hardcoded text there that doesn't have a script, so adding a script to use Language.Get seems clunky.

    2) What is the recommended way handling using different fonts for different languages? For example, if I translate into Mandarin, I will need to use a different font since my custom font does not have Chinese characters.
     
  12. Deleted User

    Deleted User

    Guest

    here is the secret!!!! always have 2 Docs, one live -w/ formulas A)., one as a pasted copy..B)..
    "select all" with core translates doc A)., copy. paste into New excel/spreadsheet C)., then import that excel/spreadsheet and overwrite, into 2nd Google doc B)...(now static, with no look-ups, No More LOADING messages...because there is NO data/translate look-up..get it? That's what worked for me
     
    Last edited by a moderator: Aug 24, 2014
    appxplore-tech likes this.
  13. Deleted User

    Deleted User

    Guest

    Look in the Localization/Resources/Languages/Assets directory - you can see there are fonts in the language subdirectories, so just add/replace as needed. Should be mentioned in the documentation (but I haven't looked at it in a long time)
     
  14. appxplore-tech

    appxplore-tech

    Joined:
    Jul 4, 2012
    Posts:
    62
    Thank you ForceVFX
     
  15. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Hi,

    I'm having a problem with this assets on mobile. Everything is localized correctly, but when for example when I close my app on iOS then change my language to English (default is NL), en restart the App it's still in Dutch (NL). But when I delete the App and reinstall it, it's in English.

    I'm using this script to localize my texts:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class NGUILocalization : MonoBehaviour {
    5.  
    6.     public string key;
    7.  
    8.     public UILabel lbl;
    9.  
    10.     void Start()
    11.     {
    12.         Localize();
    13.     }
    14.  
    15.     public void OnEnable()
    16.     {
    17.         Localize();
    18.     }
    19.  
    20.  
    21.     public void ChangedLanguage(LanguageCode code)
    22.     {
    23.         Localize();
    24.     }
    25.  
    26.     public void Localize()
    27.     {
    28.         lbl.text = Language.Get(key);
    29.     }
    30. }
    This script is attached to each UILabel in my App.
     
  16. Deleted User

    Deleted User

    Guest

    Player Pref on mobile..are you setting them? if so..are they working?? run a test!!

    not working?? need a player prefs solution for android and is FREE?? I know works.

    PlayerPrefs.cs

    Language.cs Line 21-40

    Code (csharp):
    1. static Language()
    2.     {
    3.         //        if(settings == null)
    4.         //            settings = (LocalizationSettings)Resources.Load("Languages/" + System.IO.Path.GetFileNameWithoutExtension(settingsAssetPath), typeof(LocalizationSettings));
    5.         LoadAvailableLanguages();
    6.  
    7.         bool useSystemLanguagePerDefault = settings.useSystemLanguagePerDefault;
    8.         LanguageCode useLang = LocalizationSettings.GetLanguageEnum(settings.defaultLangCode);    //ISO 639-1 (two characters). See: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
    9.  
    10.  
    11.     //See if we can use the last used language (playerprefs)
    12. !!!------------------------------------------------------------------------------------------------->>
    13.     string lastLang = PlayerPrefs.GetString("M2H_lastLanguage");
    14. !!!------------------------------------------------------------------------------------------------->>
    15.  
    16.  
    17.     if (lastLang != "" && availableLanguages.Contains(lastLang))
    18.     {
    19.         SwitchLanguage(lastLang);
    20.     }
    21.  

    Patrick Force
     
    Last edited by a moderator: Sep 22, 2014
  17. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Hi Patrick,

    I don't use PlayerPrefs on mobile, do I need them? There's nothing about that in the manual.
     
  18. Deleted User

    Deleted User

    Guest

    yes...looks like you need more help than I can offer right now..

    unless you understand this line, in the localization scripts..Language.cs..
    Code (csharp):
    1.  
    2.     //See if we can use the last used language (playerprefs)
    3. !!!------------------------------------------------------------------------------------------------->>
    4.     string lastLang = PlayerPrefs.GetString("M2H_lastLanguage");
    5. !!!------------------------------------------------------------------------------------------------->>
    6.  
    'M2H_lastLanguage' is the Key | 'EN' is the stored Value

    then you need to look for a tutorial on unity persistence data, and how you save and store data during run-time..

    p-

    how I use it..in my main menu, users select language...through a scroll view (old GUI)
    Code (csharp):
    1.  
    2. GUILayout.Label(Language.Get("MAIN_SELECT_LANGUAGE"));
    3.         scrollView = GUILayout.BeginScrollView(scrollView, GUILayout.Height(Screen.height));
    4.         foreach (string lang in Language.GetLanguages())
    5.         {
    6.             GUILayout.BeginHorizontal();
    7.             GUILayout.Space(10);
    8.             if (GUILayout.Button(lang, GUILayout.Width(50), GUILayout.Height(30)))
    9.             {
    10.                 Language.SwitchLanguage(lang);
    11.             }
    12.             GUILayout.EndHorizontal();
    13.         }
    14.         GUILayout.EndScrollView();
    15.  
    which when pressed invokes this method from Language.cs:

    Code (csharp):
    1.  
    2. Language.SwitchLanguage(lang);
    3.  
    which then switches the language based on the code you send:

    Code (csharp):
    1.  
    2.     public static bool SwitchLanguage(string langCode)
    3.     {
    4.         return SwitchLanguage(LocalizationSettings.GetLanguageEnum(langCode));
    5.     }
    6.  
    Then sets that value on a PlayerPrefs.as a key value pair. ie Languge="EN"

    and if I need another specific font: ie Chinese:

    Code (csharp):
    1.  
    2.  
    3.     void ChangedLanguage(LanguageCode code)
    4.     {
    5.         //Debug.Log("DEMO We switched to: " + code);
    6.  
    7.         if (code == LanguageCode.AR)
    8.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    9.  
    10.         if (code == LanguageCode.JA)
    11.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    12.  
    13.         if (code == LanguageCode.KO)
    14.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    15.  
    16.         if (code == LanguageCode.ZH)
    17.             GUI.skin.font = (Font)Language.GetAsset("arialbd");
    18.  
    19.         GUI.skin.button.fontSize = (int)(FontSizeMult * MyScreen.y);
    20.         GUI.skin.label.fontSize = (int)(FontSizeMult * MyScreen.y);
    21.  
    22.         Debug.Log("Font: " + GUI.skin.font);
    23.         Debug.Log("Font Size: " + GUI.skin.button.fontSize);
    24.  
    25.     }
    26.  
     
    Last edited by a moderator: Sep 23, 2014
  19. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    But why do I need to save the language data? The only thing it needs to do is switch to the System language.
     
  20. Deleted User

    Deleted User

    Guest

    1) To save users language selection, for next game session.
    2).The developer stated the reasons clearly, in an earlier post.
     
  21. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Ah I didn't read that post :) I found it and commented out the playerprefs section now it works! Thx!
     
  22. EstarCream

    EstarCream

    Joined:
    Feb 22, 2014
    Posts:
    6
    Is it possible to update the localization using an offline spread sheet?
    eg. Instead of having to be online to edit and download data from a google docs spread sheet, I can just edit an offline spread sheet with my preferred editor and update the game localization using that file.
     
  23. Goodev

    Goodev

    Joined:
    Feb 19, 2013
    Posts:
    25
    varient language is ONLY support EN_US, EN_UK and PT_BR?

    I need zh-rCN, zh-rTW

    China, Taiwan
     
  24. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Watching for purchase list!
     
  25. seno

    seno

    Joined:
    Aug 5, 2010
    Posts:
    17
    Hello.

    Could you check the support email?
    I have issue to build this localization package in iOS as "Stripping level" to be disabled.

    Thanks
     
  26. Neterea Studios

    Neterea Studios

    Joined:
    May 7, 2013
    Posts:
    23
    Hi,

    Is there any way to keep a line break?

    I need to write something like:
    News of
    the World

    But when entering the line break in the google doc cell, by ctrl + enter, it seems it's being removed when importing. I tried to add the line break manually in the .XML file and it seems to work. So the problem is that the line break is being removed on some step. I also tried with \n and   with no luck.

    Can this be done?
     
  27. Idden

    Idden

    Joined:
    May 1, 2014
    Posts:
    5
    This is a good package, can we expect support for Asset Bundles soon ?
     
  28. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    you can make it work with asset bundles quite easily. However since assetbundle building and loading is always quite custom to a game I dont see how it would make sense to supply 1 default method of doing so
     
  29. sebastiansgames

    sebastiansgames

    Joined:
    Mar 25, 2014
    Posts:
    114
    Hey I've tried emailing twice with no reply. Are you still supporting this plugin?

    I'm getting an error in Xcode (building for iOS) when attempting to play my app on my device. It seems to work fine in Unity editor play mode.

    I am using Unity 5 RC 2

    The error:
    NullReferenceException: A null value was found where an object instance was required.
    at LocalizationSettings..ctor () [0x00000] in <filename unkown>:0

    Any idea what's going on?

    Thank you.
     
  30. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I cant check right now as im away from the computer. Maybe you are calling the localization too early (awake in the first scene?). Its using Resources/ internally. Will be able to check it out early next week.
     
  31. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Hi!
    I sent you a note via contact form at http://www.m2h.nl/ but it seems to be lost.

    Google Docs changed their publishing and there's no CSV option anymore. I tried this option but M2H Localization wasn't able to fetch my spreadsheet.

    Could you please update the plugin to work with the new Docs setup?
     
  32. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Support for the new format was added a while ago, please update the plugin on the asset store and see the new updated PDF (it's just as simple really).
    Let me know if you have any further questions.

    sebastiansgames: I'm back from a week leave and will check out a U5 build on iOS (particullary the demo scene)
     
  33. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Sorry, I re-read it all and still have parsing errors:
    errors.png

    I'm using the last version (just removed and re-downloaded it to be sure) and using https://docs.google.com/spreadsheets/d/DOC_ID/pubhtml (copied from the "Publish to the web" window).
    For some reason it confuses my localization keys with sheets.

    Here's the localization (the sheet is named "game" too):
    localization.png
     
    Last edited: Mar 8, 2015
  34. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    could you please veriyfy if this is fixed if you add another sheet (just copy this first one?)
     
    Ox_ likes this.
  35. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Oh, it's working.
    I just copied the whole translation to another spreadsheet (without changing anything!), republished it and it works great.
    Thank you!
     
  36. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    So you created a new spreadsheet document instead of adding a second page?
    I'm glad it's working for you, if I figure out a fix I'll update the tool.
     
    Ox_ likes this.
  37. sebastiansgames

    sebastiansgames

    Joined:
    Mar 25, 2014
    Posts:
    114
    Thanks for looking into this, Mike. I appreciate it!
     
  38. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    @sebastiansgames:

    I tested the package and it seems to be working fine here
    I've tried the following: create a new U5 project, import the localization pacakage, and set the demo scene in the build settings.
    When I build&run the demo scene on a iPhone 6 without any problems, I was able to change the language etc.
    Xcode 6.1.1 & Unity 5.0.0f4

    What are you doing different?
    Maybe you can try the default package in an empty project as well and go from there to analyse what's the culprit?
     
  39. sebastiansgames

    sebastiansgames

    Joined:
    Mar 25, 2014
    Posts:
    114
    Okay thanks for giving it a test. Let me look into it more on my end. I appreciate it.
     
  40. gkosciolek

    gkosciolek

    Joined:
    Oct 16, 2012
    Posts:
    2
    Hi Mike

    Great asset! Thank you.

    Recently something changed at Google side and now I can't properly import translations with new line symbol in them. For example the following text:
    "Build
    Cotton Mill"

    is imported as:
    "BuildCotton Mill"

    It looks like the new line symbol is removed so I have the whole string in one line.

    Could you, please, take a look at this?

    Kind regards,
    Grzegorz
     
  41. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    Same problem. The exported document contains <br> tags, but the parser ignores them. Fixed by adding
    Code (CSharp):
    1. tdNode.InnerHtml = tdNode.InnerHtml.Replace("<br>", "\n");
    before
    Code (CSharp):
    1. string content = tdNode.InnerText;
    in LanguageEditor.ParseHTMLTable.
     
    BonitaPersona, gkosciolek and OnePxl like this.
  42. gkosciolek

    gkosciolek

    Joined:
    Oct 16, 2012
    Posts:
    2
    Thank you very much! Worked brilliantly.
     
  43. seno

    seno

    Joined:
    Aug 5, 2010
    Posts:
    17
    Hello, Mike.

    Like many users of this asset, It's really great assets. I used it with two consecutive commercial projects!

    However, I would like to ask you for idea to fetchable localization files with your asset.
    I looked short time inside this assets, but it seems to update table name list in editor mode, but couldn't figure out way to use in run time.

    I wonder you can give me some direction to update the assets. Adding it to the next feature also will be great!

    Thanks for the great asset!
     
  44. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Google added a footer to published files. It fails the plugin's parser and then freezes Unity:
    google-publishing.png
     
  45. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Its still working fine here. Are you using the latest version from the unity asset store? If so, could you link me your document URL so I can test&fix?
     
  46. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    I update it less than 2 months ago last time.

    Sent you link in PM.
     
  47. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Made a fix for this new google change and submitted this as v1.18. Not sure how quickly Unity reviews the asset store packages. Could be live tomorrow(?).

    Only LanguageEditor.cs has changed.
     
    Ox_ likes this.
  48. Deleted User

    Deleted User

    Guest

    I need this fix...what do I need to do??

    Sheet Report Abuse contains no languages!
    UnityEngine.Debug:LogError(Object)
    LanguageEditor:parseData(String, String, Int32) (at Assets/Localization/Editor/LanguageEditor.cs:358)

    LanguageEditor.cs

    What line number??, just comment whole section looking for more sheets??, greater than 1 section..??

    Did it break the system?

    p-
     
    Last edited by a moderator: May 27, 2015
  49. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Did you already update the plugin with the May 18 fix?
    Otherwise, can you share your spreadsheet URL in a PM so I can have a look?
     
  50. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    It's still not working here, even with the latest fix. This is really becoming a serious problem for me, so I'll send you the spreadsheet URL in PM.