Lightweight localization for a Cordova app
AFAIK, accessing local files using XMLHttpRequest won't be a problem once you have your page up on a web server.

Anyway, if you decide to go with the solution above, here are some general tips:


getString() method:


Use this.translation rather than window['locale']['translation']. There no point traversing to window and back again when you can use the this pointer.
Try to be more descriptive when naming variables and methods. For example, the required argument. If a third party user is using your API, how would they pssobile know what to pass? A string? An object?

translation object:


Your language objects have some indentical values. To be less repetitive, create a default object and merge with each new language. I will use jQuery.extend() in my example.

Misc:


Create an object that keeps track of your constants and reuse it throughout your module.



The code could look something like this:



var locale = {

    constants: {
        language: {
            localStorageKey: 'language',
            default: 'nl'
        }
    },

    getTranslationByLanguage:function(languageProperty){

        if(!languageProperty) 
            throw new ReferenceError('languageProperty not defined');

        var language = localStorage.getItem(this.constants.language.localStorageKey) 
                       || this.constants.language.default;

        var translation = this.translation.getTranslationByLanguageKey(language);

        return translation[languageProperty];
    },

    translation: {

        defaults: {
            faq: 'FAQ',
            highscore: 'highscore'
        },

        en: {
            play:'Play',
            gameStart:'Game starting in '
        },

        nl: {
            play:'Speel',
            gameStart:'Spel start in '
        },

        getTranslationByLanguageKey: function(languageKey){
            return $.extend({}, this.defaults, this[languageKey] || {});
        }

    }
};