Tiny l10n localization library for Phonegap/Cordova applications
CoffeeScript JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENCE.txt
README.md
localization.coffee
localization.js

README.md

phonegap-l10n

Tiny l10n localization library for Phonegap/Cordova applications. Can be used for localizing your application in a declarative way, or programmatically.

How to use it:

Somewhere in your onDeviceReady() callback, initialize the library:

Localization.initialize
(
    // Dictionnary
    { 
        fr: {
            oui: "Oui",
            non: "Non"
        },

        en: {
            oui: "Yes",
            non: "No"
        }

    },
    // Fallback language
    "fr"
);

In your HTML code, localize your strings declaratively, by assigning a class "l10n-" to your elements:

<span class="l10n-oui"></span>

You can also access the dictionnary programmatically:

alert(Localization.for("oui"))

Language is determined by phonegap, by reading the language configured on the phone. In case the language is not available in the dictionnary, or if there is any problem determining the language, the fallback language is used.