2

I have a working Phonegap app which is currently in danish, but i need to translate it to several other languages.

I have never worked with localization before, but the concept seems pretty straight-forward.

I found a localization-library ([http://www.localeplanet.com/index.html][1])

In the HOWTO-section on the site there are some examples like the one below:

alert(_('Hello, world!'));

So if i have an alert box like this

navigator.notification.alert(
    'Logging in',
    function () { },
    'Your user has been created',
    'Ok'
);

I simply translate it like so:

navigator.notification.alert(
    _('Logging in'),
    function () { },
    _('Your user has been created'),
    _('Ok')
);

But what about "hardcoded" text? For example I have a lot of buttons like this:

<button>Continue job</button>    
<button>Cancel job</button>    
<button>Go back</button>    

Do i have to give each and every button in my app an ID and the set the text with, for example, $.text()?

EDIT: im looking for something like this

<?=$var?>

but in regular html not php

FlyingHippo
  • 177
  • 2
  • 12

1 Answers1

0

you can use a function to take all 'button's and replace the current text with translated text.

$.("button").each(function (){
    translateText($(this).text(), $(this));
});