Localization for Android in Corona SDK

Hi there,

This might be a newbie question, but I’m first trying Corona and after some fiddling about, was wondering how localization (i18n) can be achieved for Android builds. I’ve seen some information on localization when building for iOS, but couldn’t find anything regarding Android.

I must admit that even though I have a background in computer programming, I’m new to developing for Android, so maybe this is something that’s handled outside of Corona, but I really don’t know. I’ve searched around the documentation and googled about it for a few days, but couldn’t find anything related to this.

Any help would be greatly appreciated. I obviously don’t expect a tutorial on localization, but just a link or two pointing me in the right direction would already be pretty helpful.

Thanks in advance, and sorry if this has been asked before.

If you mean localising your actual app then that is a manual process needing to be done in code.

1 Like

Hi,
I also use a custom method, because for what I know, Solar2D doesn’t support the standard “strings.xml” localization.
I googled just to see if there’s any shared solution and I found something interesting:

1 Like

If you are talking about in-game strings, I use my own solution(here). There are also other alternatives out there that you can probably find on forums or asking people on Discord.

1 Like

@bgmadclown I do a similar thing but combine my languages. I also allow for wild card replacements.

Sample of data store (might help others)

	["build <> residential buildings"] = {
	["de"] = "baue <> Wohngebäude",
	["id"] = "bangun <> bangunan hunian",
	["it"] = "costruisci <> edifici residenziali",
	["ja"] = "住居施設を <> 軒建てる",
	["ru"] = "Построить <> жилых зданий",
	["fr"] = "construire <> bâtiments résdentiels",
	["nl"] = "bouw <> woningen",
	["es"] = "Construir <> Edificios residenciales",
	["pt"] = "constrói <> edifícios residenciais",
	["ko"] = "<> 주거용 건물 건축",
},

if the translation is EN then no lookup is required, if not then it is a simple table look up to select the right string for the requested language.

2 Likes

Yes, I meant localizing a game made with Corona, not the Corona Simulator itself, sorry for the confusion.

Thanks to all for your replies, that all makes perfect sense. Coding my own localization should be a breeze, just didn’t want to reinvent the wheel in case that was already done, or break anything with the Google Play Store in case it was expecting some specific way to localize.

Last thing I need then is how to retrieve the device’s locale/culture. I’ve looked at the system.getInfo() docs, but couldn’t find anything that seemed related.

1 Like

Nevermind, just found it. For reference to anybody checking this thread in the future, it’s retrieved with system.getPreference( "ui", "language" ), system.getPreference( "locale", "identifier" ) or system.getPreference( "locale", "language" ), with some caveats as detailed in http://docs.coronalabs.com/api/library/system/getPreference.html

1 Like

I think the question is just outside of the engine functions (though you can create your own l18n method). Is it more about the core it works on, the OS. As for Android, check this link:
https://developer.android.com/guide/topics/resources/localization

I used that reference to apply a different icon name on a device if there is a different OS language. You can use same methods for interface languages as well, by crateing xml-files in language directories.

1 Like

If anyone is still interested, GBC Language Cabinet, my free plugin on the Free Plugin Directory will help with in-app localization.

3 Likes

I am using GBC Language Cabinet plugin for localization, just linked in post above. It works great!

2 Likes