I18n aka Internationalization and localization

4 posts / 0 new
Last post
Miguel Augusto
miguelmaugusto's picture
Offline
Mobile Wizard
Joined: 19 Dec 2011
Posts:
I18n aka Internationalization and localization

Hi,

Has anybody here developed an app with I18n features? Anyone suggests any way of going about it?
I used to use *.properties with struts2 and java, but with MoSync I believe it should be very different. Maybe xml files (some kind of simple stucture), or an other simple method.

Right now I'm very open to suggestions, so shoot'em up, plz. :-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

In my AppMancer projects, I use a class called AppText, which provides me with app text from XML. I've attached the code below, but it requires the AppMancer AMXml library.

I think that XML is probably the way to go, but with MoSync 3.0 then there is a new resource compiler which can condtionally add all sorts of extras per platform or release, so you can easily add in different language .lst files as well, which will have a lower overhead.

Miguel Augusto
miguelmaugusto's picture
Offline
Mobile Wizard
Joined: 19 Dec 2011
Posts:
rival wrote:

In my AppMancer projects, I use a class called AppText, which provides me with app text from XML. I've attached the code below

Where? I didn't find your AppText class.

btw,
Thanks for allways replying so promptly, Sam.
You're truly being a great help to the MoSync Comunity! :-)

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Doh - I forgot the files! Put the XML into your resources

// You can hold all of the text your application displays in external XML files
.res LANGUAGE_EN
.ubin
.include "Languages/en-GB.xml"

, and call AppText::setLanguageFile(LANGUAGE_EN); when you start the app. You can create as many language XML files as you may want, and add then to the resources. I often add en-GB.xml and fr-FR.xml for example, and can then switch language with one line, or even let the user choose.

You can then write lines like:

Label* l = createLabel(AppText::getText("WelcomeMessage"));

Which will put the inner text property of the Xml node 'WelcomeMessage' into the label.

The Xml should look something like this:

<apptext>
	<WelcomeMessage>Welcome.</WelcomeMessage>
	<Menu>Menu</Menu>
	<Exit>Exit</Exit>
	<Home>Home</Home>
	<Back>Back</Back>
	<OK>OK</OK>
	<AlertMessage>Self-destruct in 29 seconds...</AlertMessage>
	<LorumIpsum>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae dolor id erat tristique scelerisque. </LorumIpsum>
	<Calendar>Calendar</Calendar>
	<EnterName>Enter your name</EnterName>
</apptext>

As I said earlier, this is dependent on AMXml, but you can take this approach without using it as well.

AttachmentSize
AppText.zip 1.8 KB