define( function() {

    var fallbackLanguage = "en-us",
        texts = {
    "player": {
        "navigation": {
            "button": {
                "repeat": {
                    "et-ee": "Korda",
                    "bg-bg": "Повторение",
                    "cs-cz": "Opakovat",
                    "da-dk": "Gentag",
                    "de-de": "Wiederholen",
                    "en-us": "Repeat",
                    "es-es": "Repetir",
                    "es-ar": "Repetir",
                    "fi-fi": "Toista",
                    "fr-fr": "Répéter",
                    "el-gr": "Επανάληψη",
                    "hi-in": "दोहराएँ",
                    "hr-hr": "Ponovi",
                    "hu-hu": "Ismétlés",
                    "it-it": "Ripeti",
                    "ja-jp": "繰り返す",
                    "ko-kr": "반복",
                    "lt-lt": "Kartoti",
                    "mk-mk": "Повтори",
                    "mn-mn": "Давтах",
                    "ms-id": "Ulangi",
                    "nl-nl": "Herhalen",
                    "no-no": "Gjenta",
                    "pl-pl": "Potwórz",
                    "pt-pt": "Repetir",
                    "pt-br": "Repetir",
                    "ro-ro": "Repetare",
                    "ru-ru": "Повторить",
                    "sk-sk": "Opakovať",
                    "sl-si": "Ponovi",
                    "sr-rs": "Ponoviti",
                    "sv-se": "Upprepa",
                    "th-th": "เล่นซ้ำ",
                    "tr-tr": "Tekrarla",
                    "zh-tw": "重複",
                    "zh-cn": "重复",
                    "de-at": "Wiederholen",
                    "de-ch": "Wiederholen",
                    "eo-de": "Wiederholen",
                    "nl-be": "Herhalen",
                    "en-ie": "Repeat",
                    "en-gb": "Repeat",
                    "eo-en": "Wiederholen",
                    "fr-be": "Répéter"
                }
            }
        }
    }
};

    /**
     * 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;
        }
    }
});