Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Translation problem
Started by Caithan Games Jul 02 2014 06:07 AM

- - - - -
3 replies to this topic
localization translation widgets buttons
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Caithan Games

[GLOBAL: userInfoPane.html]
Caithan Games
  • Enthusiast

  • 63 posts
  • Corona SDK

Hi all...

 

I'm just about to localize one of my apps in Korean and Japanese. Translation seems easy enough with generic text strings, using a 'required table', but I can't seem to adapt that way of thinking to widgets!

 

Basically, I can't localize my widget-button labels. Does anyone have any experience of this, or can you point me to a decent resource.

 

Thanks



[TOPIC: post.html]
#2

AlanPlantPot

[GLOBAL: userInfoPane.html]
AlanPlantPot
  • Contributor

  • 733 posts
  • Corona SDK

Were exactly are you stuck with this.  

 

I don't use button widgets very often, but from what I remember they are something like this:

local button = widget.newButton
{
    width = 100,
    height = 50,
    defaultFile = "buttonDefault.png",
    overFile = "buttonOver.png",
    label = "my button text",
    onEvent = myButtonEvent
}

Instead of providing a literal string, just do something like this:

local buttonStrings = {
						en = "my button text",
						fr = "mon texte du bouton",
						it = "il mio testo del pulsante",
						de = "meine Button-Text",
						es = "mi texto del botón",
						ko = "내 단추 텍스트",
						jp = "私のボタンのテキスト",

}

--get the user's 2 letter language code
local usersLanguage = system.getPreference("ui", "language")

--make it's lower case
usersLanguage = string.lower( usersLanguage )

--just use first 2 letters, in case they have a regional dialect
if string.len(usersLanguage) > 2 then usersLanguage = string.sub(usersLanguage, 1, 2) end



local button = widget.newButton
{
    width = 100,
    height = 50,
    defaultFile = "buttonDefault.png",
    overFile = "buttonOver.png",
    label = buttonStrings[usersLanguage],
    onEvent = myButtonEvent
}

The label reads from a table of potential phrases, and picks the correct one based on the user's language.

 

Since I don't always use regional dialects (e.g. en-gb, en-us), I just use the first 2 characters in the language code.



[TOPIC: post.html]
#3

Caithan Games

[GLOBAL: userInfoPane.html]
Caithan Games
  • Enthusiast

  • 63 posts
  • Corona SDK

Thanks a bundle, Mr plantpot, that works a treat... I was just struggling with [stuff that goes in here] and how to bring it into the label.

 

I also have a few graphic elements in my game, that it would be nice to localise... For example, there's a newspaper on the floor in a particular scene (the headline is in english). It would be nice to swap out images, based on 'system.getPreference', but I've not worked that out yet either.

 

Thanks again. Really helpful.

 

M



[TOPIC: post.html]
#4

Caithan Games

[GLOBAL: userInfoPane.html]
Caithan Games
  • Enthusiast

  • 63 posts
  • Corona SDK

...Just as an addition to this thread, because I'm pretty sure it will be useful to lots more Developers...

 

Different languages look better in different fonts. Just wondering if you can assign a font to a language pref'... If so, how? Hmmm




[topic_controls]
[/topic_controls]