define( function() {

    var fallbackLanguage = "en-us",
        texts = {
    "player": {
        "navigation": {
            "button": {
                "back": {
                    "et-ee": "Tagasi",
                    "bg-bg": "Назад",
                    "cs-cz": "Zpět",
                    "da-dk": "Tilbage",
                    "de-de": "Zurück",
                    "en-us": "Back",
                    "es-es": "Atrás",
                    "es-ar": "Atrás",
                    "fi-fi": "Edellinen",
                    "fr-fr": "Retour",
                    "el-gr": "Προηγούμενο",
                    "hi-in": "पीछे",
                    "hr-hr": "Natrag",
                    "hu-hu": "Vissza",
                    "it-it": "Indietro",
                    "ja-jp": "戻る",
                    "ko-kr": "뒤로",
                    "lt-lt": "Atgal",
                    "mk-mk": "Назад",
                    "mn-mn": "Буцах",
                    "ms-id": "Kembali",
                    "nl-nl": "Terug",
                    "no-no": "Tilbake",
                    "pl-pl": "Wstecz",
                    "pt-pt": "Retroceder",
                    "pt-br": "Retroceder",
                    "ro-ro": "Înapoi",
                    "ru-ru": "Назад",
                    "sk-sk": "Späť",
                    "sl-si": "Nazaj",
                    "sr-rs": "Nazad",
                    "sv-se": "Tillbaka",
                    "th-th": "ย้อนกลับ",
                    "tr-tr": "Geri",
                    "zh-tw": "返回",
                    "zh-cn": "返回",
                    "de-at": "Zurück",
                    "de-ch": "Zurück",
                    "eo-de": "Zurück",
                    "nl-be": "Terug",
                    "en-ie": "Back",
                    "en-gb": "Back",
                    "eo-en": "Zurück",
                    "fr-be": "Retour"
                }
            }
        }
    }
};

    /**
     * Gets data from a nested object
     *
     * @private
     * @param {string} key - a dot separated representation of the objectstructure e.g.("cmi.core.lesson_status")
     * @param {object|string} data - the data object where the value should be got from
     */
    function getData( key, data ) {

        var parts = key.split("."),
            i = 0,
            parent = data;

        for(; i < parts.length; ++i) {
            if (!parent[parts[i]]) {
                return null;
            }
            parent = parent[parts[i]];
        }

        return parent;
    }

    // revealing public API
    return {

        /**
         * Gets a text in a given language
         * If the text is not defined in the given language, the text in teh fallback "en-us" is used, otherwise "null".
         *
         * @public
         * @param {string} key - a dot separated representation of the resource e.g.("quiz.evaluate")
         * @param {string} [language] - the language for the text e.g.("en-us")
         */
        get : function( key, language ){

            var text = getData( key, texts );
            if( text ){
                return getData( language, text ) || getData( fallbackLanguage, text );
            }

            return null;
        }
    }
});