define( function() {

    var fallbackLanguage = "en-us",
        texts = {
    "player": {
        "sound": {
            "onoff": {
                "et-ee": "Heli sisse-välja",
                "bg-bg": "Включване/изключване на звука",
                "cs-cz": "Vypnout/zapnout zvuk",
                "da-dk": "Lyd til/fra",
                "de-de": "Ton an - aus",
                "en-us": "Sound on - off",
                "es-es": "Sonido si - no",
                "es-ar": "Sonido si - no",
                "fi-fi": "Ääni päälle - pois",
                "fr-fr": "Son on - off",
                "el-gr": "Ενεργοποίηση - απενεργοποίηση ήχου",
                "hi-in": "ध्वनि चालू - बंद",
                "hr-hr": "Uključi ‒ isključi zvuk",
                "hu-hu": "Hang be - ki",
                "it-it": "Audio on - off",
                "ja-jp": "音声オン/オフ",
                "ko-kr": "사운드 켜기 - 끄기",
                "lt-lt": "Garso įjungimas (išjungimas)",
                "mk-mk": "Вклучи - Исклучи звук",
                "mn-mn": "Дуутай - Дуугүй",
                "ms-id": "Suara hidup - mati",
                "nl-nl": "Geluid aan – uit",
                "no-no": "Lyd på – av",
                "pl-pl": "Dźwięk wł. - wył.",
                "pt-pt": "Som ligado - desligado",
                "pt-br": "Som ligado - desligado",
                "ro-ro": "Sunet pornit - oprit",
                "ru-ru": "Вкл - выкл звук",
                "sk-sk": "Zvuk zapnúť/vypnúť",
                "sl-si": "Vklop/izklop zvoka",
                "sr-rs": "Uključi - isključi zvuk",
                "sv-se": "Ljud av – på",
                "th-th": "เปิด - ปิดเสียง",
                "tr-tr": "Ses açık - kapalı",
                "zh-tw": "開啟/關閉音效",
                "zh-cn": "声音开 - 关",
                "de-at": "Ton an - aus",
                "de-ch": "Ton an - aus",
                "eo-de": "Ton an - aus",
                "nl-be": "Geluid aan – uit",
                "en-ie": "Sound on - off",
                "en-gb": "Sound on - off",
                "eo-en": "Ton an - aus",
                "fr-be": "Son on - off"
            }
        }
    }
};

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