define( function() {

    var fallbackLanguage = "en-us",
        texts = {
    "player": {
        "quiz": {
            "result": {
                "back_to_test_question": {
                    "et-ee": "Tagasi testküsimuse juurde",
                    "bg-bg": "Обратно към тестовия въпрос",
                    "cs-cz": "Zpět k testovací otázce",
                    "da-dk": "Tilbage til testspørgsmål",
                    "de-de": "Zurück zur Testfrage",
                    "en-us": "Back to test question",
                    "es-es": "Volver a la pregunta de prueba",
                    "es-ar": "Volver a la pregunta de prueba",
                    "fi-fi": "Takaisin testikysymykseen",
                    "fr-fr": "Retour à la question test",
                    "el-gr": "Επιστροφή στη δοκιμαστική ερώτηση",
                    "hi-in": "प्रश्न का परीक्षण करने के लिए वापस",
                    "hr-hr": "Natrag na test pitanje",
                    "hu-hu": "Vissza a teszt kérdéshez",
                    "it-it": "Torna alla domanda di prova",
                    "ja-jp": "テストの質問に戻る",
                    "ko-kr": "테스트 질문으로 돌아 가기",
                    "lt-lt": "Grįžti prie bandomojo klausimo",
                    "mk-mk": "Назад на тест прашање",
                    "mn-mn": "Туршилтын асуулт руу буцах",
                    "ms-id": "Kembali ke pertanyaan tes",
                    "nl-nl": "Terug naar testvraag",
                    "no-no": "Tilbake til testspørsmål",
                    "pl-pl": "Powrót do pytania testowego",
                    "pt-pt": "Voltar para a pergunta de teste",
                    "pt-br": "Voltar para a pergunta de teste",
                    "ro-ro": "Înapoi la întrebarea de testare",
                    "ru-ru": "Вернуться к тесту",
                    "sk-sk": "Späť k testovacej otázke",
                    "sl-si": "Nazaj na preizkusno vprašanje",
                    "sr-rs": "Повратак на тест питање",
                    "sv-se": "Tillbaka till testfrågan",
                    "th-th": "กลับไปที่คำถามทดสอบ",
                    "tr-tr": "Test sorusuna dön",
                    "zh-tw": "返回測試題",
                    "zh-cn": "返回测试题",
                    "de-at": "Zurück zur Testfrage",
                    "de-ch": "Zurück zur Testfrage",
                    "eo-de": "Zurück zur Testfrage",
                    "nl-be": "Terug naar testvraag",
                    "en-ie": "Back to test question",
                    "en-gb": "Back to test question",
                    "eo-en": "Zurück zur Testfrage",
                    "fr-be": "Retour à la question test"
                }
            }
        }
    }
};

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