define( function() {

    var fallbackLanguage = "en-us",
        texts = {
    "player": {
        "animated": {
            "videocontrolbutton": {
                "play": {
                    "bg-bg": "Възпроизвеждане",
                    "cs-cz": "Hrát si",
                    "da-dk": "Spil",
                    "de-at": "Wiedergabe",
                    "de-de": "Wiedergabe",
                    "de-ch": "Wiedergabe",
                    "el-gr": "Παίζω",
                    "en-ie": "Play",
                    "en-gb": "Play",
                    "en-us": "Play",
                    "eo-en": "Wiedergabe",
                    "eo-de": "Wiedergabe",
                    "es-es": "Siguiente",
                    "es-ar": "Siguiente",
                    "et-ee": "Tocar",
                    "fi-fi": "Pelata",
                    "fr-be": "Jouer",
                    "fr-fr": "Jouer",
                    "hi-in": "खेल",
                    "hr-hr": "Igra",
                    "hu-hu": "Játék",
                    "it-it": "Giocare",
                    "ja-jp": "演奏する",
                    "ko-kr": "플레이",
                    "lt-lt": "Žaisti",
                    "mk-mk": "Играј",
                    "mn-mn": "Тоглуулах",
                    "ms-id": "Main",
                    "nl-be": "Speel",
                    "nl-nl": "Speel",
                    "no-no": "Spille",
                    "pl-pl": "Grać",
                    "pt-pt": "Toque",
                    "pt-br": "Toque",
                    "ro-ro": "Joaca",
                    "ru-ru": "Играть в",
                    "sk-sk": "Hrať",
                    "sl-si": "Igraj",
                    "sr-rs": "Игра",
                    "sv-se": "Spela",
                    "th-th": "เล่น",
                    "tr-tr": "Oyna",
                    "zh-tw": "玩",
                    "zh-cn": "玩"
                },
                "pause": {
                    "bg-bg": "Прекъсване",
                    "cs-cz": "Přestávka",
                    "da-dk": "Pause",
                    "de-at": "Anhalten",
                    "de-ch": "Anhalten",
                    "de-de": "Anhalten",
                    "el-gr": "Διακοπή ",
                    "en-ie": "Pause",
                    "en-gb": "Pause",
                    "en-us": "Pause",
                    "eo-de": "Anhalten",
                    "eo-en": "Anhalten",
                    "es-es": "Rotura",
                    "es-ar": "Rotura",
                    "et-ee": "Break",
                    "fi-fi": "Tauko",
                    "fr-be": "Casser",
                    "fr-fr": "Casser",
                    "hi-in": "टूटना",
                    "hr-hr": "Pauza",
                    "hu-hu": "Szünet",
                    "it-it": "Rompere",
                    "ja-jp": "ブレーク",
                    "ko-kr": "단절",
                    "lt-lt": "Pertrauka",
                    "mk-mk": "Пауза",
                    "mn-mn": "Завсарлага",
                    "ms-id": "Rehat",
                    "nl-be": "Breken",
                    "nl-nl": "Breken",
                    "no-no": "Gå i stykker",
                    "pl-pl": "Przerwa",
                    "pt-pt": "Intervalo",
                    "pt-br": "Intervalo",
                    "ro-ro": "Pauză",
                    "ru-ru": "Перемена",
                    "sk-sk": "Prestávka",
                    "sl-si": "Odmor",
                    "sr-rs": "Пауза",
                    "sv-se": "Ha sönder",
                    "th-th": "หยุดพัก",
                    "tr-tr": "Break",
                    "zh-tw": "休息",
                    "zh-cn": "休息"
                },
                "stop": {
                    "bg-bg": "Да спра ",
                    "cs-cz": "Zastavit",
                    "da-dk": "Stoppen",
                    "de-at": "Stoppen",
                    "de-ch": "Stoppen",
                    "de-de": "Stoppen",
                    "el-gr": "Να σταματήσει",
                    "en-ie": "Stop",
                    "en-gb": "Stop",
                    "en-us": "Stop",
                    "eo-de": "Stoppen",
                    "eo-en": "Stop",
                    "es-es": "Para detener",
                    "es-ar": "Para detener",
                    "et-ee": "Peatuma ",
                    "fi-fi": "Pysähtyä",
                    "fr-be": "Arrêter",
                    "fr-fr": "Arrêter",
                    "hi-in": "रोक लेना",
                    "hr-hr": "Zaustaviti",
                    "hu-hu": "Megállni",
                    "it-it": "Fermare",
                    "ja-jp": "止まる",
                    "ko-kr": "그만하다",
                    "lt-lt": "Sustoti",
                    "mk-mk": "Да престане",
                    "mn-mn": "Зогсох",
                    "ms-id": "Untuk berhenti",
                    "nl-be": "Stoppen",
                    "nl-nl": "Stoppen",
                    "no-no": "Å stoppe",
                    "pl-pl": "Zatrzymać",
                    "pt-pt": "Parar",
                    "pt-br": "Parar",
                    "ro-ro": "A opri",
                    "ru-ru": "Прекратить",
                    "sk-sk": "Prestať",
                    "sl-si": "Ustaviti",
                    "sr-rs": "Да се ​​заустави",
                    "sv-se": "Att stanna",
                    "th-th": "เพื่อหยุด",
                    "tr-tr": "Durdurmak için",
                    "zh-tw": "停止",
                    "zh-cn": "停止"
                }
            }
        }
    }
};

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