define( function() {

    var fallbackLanguage = "en-us",
        texts = {
    "player": {
        "animated": {
            "video": {
                "label": {
                    "et-ee": "Väljas",
                    "bg-bg": "Изключено",
                    "cs-cz": "Vypnuto",
                    "da-dk": "Af",
                    "de-de": "An",
                    "en-us": "On",
                    "es-es": "Apagado",
                    "es-ar": "Apagado",
                    "fi-fi": "Vinossa",
                    "fr-fr": "Éteint",
                    "el-gr": "Μακριά από",
                    "hi-in": "बंद",
                    "hr-hr": "Isključeno",
                    "hu-hu": "Ki",
                    "it-it": "Off",
                    "ja-jp": "オフ",
                    "ko-kr": "떨어져서",
                    "lt-lt": "Išjungta",
                    "mk-mk": "Исклучено",
                    "mn-mn": "Унтраалттай",
                    "ms-id": "Mati",
                    "nl-nl": "Uit",
                    "no-no": "Av",
                    "pl-pl": "Poza",
                    "pt-pt": "Fora",
                    "pt-br": "Fora",
                    "ro-ro": "Dezactivat",
                    "ru-ru": "Выключенный",
                    "sk-sk": "Vypnuté",
                    "sl-si": "Izklopljeno",
                    "sr-rs": "Ван",
                    "sv-se": "Av",
                    "th-th": "ปิด",
                    "tr-tr": "Kapalı",
                    "zh-tw": "離開",
                    "zh-cn": "离开",
                    "de-at": "An",
                    "de-ch": "An",
                    "eo-de": "An",
                    "nl-be": "Uit",
                    "en-ie": "On",
                    "en-gb": "On",
                    "eo-en": "An",
                    "fr-be": "Éteint"
                }
            }
        }
    }
};

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