FirefoxOS app Localization, the Javascript side of things

After playing around with adding several languages for my app’s HTML interface on the previous post I began researching how to use this setup to change strings on the JavaScript side depending on the settings language.

After a look at Gaia’s source code, it turns out it is actually pretty easy to access the string variables from the last post’s setup. Using the same example from that post, from JavaScript we could do

var loadVariable = navigator.mozL10n.get('loading');

var EmpPlayVariable = navigator.mozL10n.get('EmptyPlaylist');

var SaveCurVariable = navigator.mozL10n.get('SaveCurrent');

var LoadCurVariable =navigator.mozL10n.get('LoadCurrent');

var AddWhVariable =navigator.mozL10n.get('AddWhole'); 

And now we have a group of variables loaded with the correct translated value, directly from the appropriate property file. Easy


An upcoming web developer and android app-maker with an interest on using reliable tech in creative ways, open source projects and start-ups.

Tagged with: , ,
Posted in developer tips
2 comments on “FirefoxOS app Localization, the Javascript side of things
  1. Keerthi Chandra says:

    Reblogged this on Keerthi Chandra.

  2. Monica says:

    Hey Sajirdalas,
    Great post.Thanks for sharing this with the code.Really helpful.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: