Getting localization right once and for all

I am in the process of releasing my new game “Feather” on the iOS App Store and I wanted to release it in various languages, first of which will be Spanish.

After reading these various posts across the web and this forum, I’m halfway there.

http://forums.coronalabs.com/topic/12191-language-localization-foreign-language-apps-build-settings/

http://stackoverflow.com/questions/12146750/where-cfbundlename-is-being-used

http://forums.coronalabs.com/topic/38972-does-corona-support-app-name-localization

http://lauratallardy.com/app-localization-made-easy/

In my app, I use this code to test for alternate languages:

\_G.language = system.getPreference( "ui", "language" ) if string.find( \_G.language, "es%-" ) ~= nil then \_G.language = "es" end if string.find( \_G.language, "en%-" ) ~= nil then \_G.language = "en" end -- failsafe language mode if \_G.language ~= "es" and \_G.language ~= "en" then \_G.language = "en" end

I had to add the string.find statements because iOS once returned  es-MX for Español (Mexíco), and I figured it could also return en-GB for Great Britain.

With _G.language  variable properly set, I am able use a statement like logo = display.newImageRect( “logo_” … _G.language … “.png” ) to access logo_en.png and logo_es.png for the localized graphic titles, for example.

Ok, so that’s settled.  Now, in my build.settings file, I’ve added the CFBundleLocalizations section:

settings = { plugins = { ... }, orientation = { ... }, iphone = { plist = { MinimumOSVersion = "7.0", UIPrerenderedIcon = true, UIStatusBarHidden = true, ... CFBundleLocalizations = { "es", "en", } }, }, ... }

And I created both es.lproj and en.lproj  root folders, both with InfoPlist.strings files.  The  InfoPlist.strings  file in the es.lproj folder contains:

CFBundleDisplayName = “Pluma”; CFBundleName = “Pluma”;

Now, when I compile and place on my iPhone, it says Feather under the app’s icon, not Pluma when I change the Language settings to Español or Español (Mexíco).  I’ve even tried creating another root folder called es-MX.lproj with the same file, but still the app remains as Feather.  What am I doing wrong?  :frowning:

Has anyone got localization working on their app such that it shows up with a different word or phrase when the iOS device is placed in a different UI language?  If so, can you post your build.settings and your InfoPlist.strings file?  This is really frustrating.

Very interested to learn about this as well. Good luck in your investigations. 

Hey BeyondtheTech,

Glad to see my tutorial getting some use! :slight_smile:

I ran a basic test and was able to get localized titles Feather and Pluma for English and Spanish, the only difference I can see is I’ve been spelling out the names of the languages in build.settings (“English” instead of “en”.)

I wrapped up the test files, you can download them and grab the code from this link: http://lauratallardy.com/wp-content/uploads/2014/03/localization_test.zip

Hope this helps!

Laura

Very, very strange.  I looked at my code and files/folder setups and yes, the only thing that seemed different was the " en"  vs. " English" and even after I changed it, it still didn’t work.

I got desperate and deleted my en.lproj and es.lproj folders (and their appropriate  InfoPlist.strings files) and copied yours into my source folder, then recompiled.  It worked!

I swear, I looked at the names of the folders and the contents of the .strings files and they are identical.  That was an exercise in frustration, but thank you for resolving it!

You’re welcome- glad it worked! Sometimes you just have to start from the ground up again, lol. darn gremlins!

One other thought, the info.plist file you pasted was this: 

CFBundleDisplayName = “Pluma”;

CFBundleName = “Pluma”;

Those “” quotations might be like the wrong kind, like from Word. like see the difference between 

CFBundleDisplayName = “Pluma”;

and 

CFBundleDisplayName = “Pluma”;

? That might have been throwing things off.

Has anyone got localization working on their app such that it shows up with a different word or phrase when the iOS device is placed in a different UI language?  If so, can you post your build.settings and your InfoPlist.strings file?  This is really frustrating.

Very interested to learn about this as well. Good luck in your investigations. 

Hey BeyondtheTech,

Glad to see my tutorial getting some use! :slight_smile:

I ran a basic test and was able to get localized titles Feather and Pluma for English and Spanish, the only difference I can see is I’ve been spelling out the names of the languages in build.settings (“English” instead of “en”.)

I wrapped up the test files, you can download them and grab the code from this link: http://lauratallardy.com/wp-content/uploads/2014/03/localization_test.zip

Hope this helps!

Laura

Very, very strange.  I looked at my code and files/folder setups and yes, the only thing that seemed different was the " en"  vs. " English" and even after I changed it, it still didn’t work.

I got desperate and deleted my en.lproj and es.lproj folders (and their appropriate  InfoPlist.strings files) and copied yours into my source folder, then recompiled.  It worked!

I swear, I looked at the names of the folders and the contents of the .strings files and they are identical.  That was an exercise in frustration, but thank you for resolving it!

You’re welcome- glad it worked! Sometimes you just have to start from the ground up again, lol. darn gremlins!

One other thought, the info.plist file you pasted was this: 

CFBundleDisplayName = “Pluma”;

CFBundleName = “Pluma”;

Those “” quotations might be like the wrong kind, like from Word. like see the difference between 

CFBundleDisplayName = “Pluma”;

and 

CFBundleDisplayName = “Pluma”;

? That might have been throwing things off.