HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/topswtwmobile.komma.pro/wwwroot/js/app/modules/translations.js
define([], function () {


    return translation = function () {

        var langItems = null;

        $.ajaxSetup({
            async: false
        });

        this.initialize = function () {

            lang_url = '/ajax/translations';
            var url_parts = window.location.pathname.split('/')
            if (url_parts[1].match(/[a-z]{2}/gi)) {
                lang_url = '/' + url_parts[1] + lang_url;
            }
            $.getJSON(lang_url, function (data) {
                langItems = data;
            });
        }

        this.get = function (path) {

            //Split the parts in to an array
            var pathParts = path.split('.');
            var translationLevel = langItems;

            for (var pathPart in pathParts) {
                pathPart = pathParts[pathPart];
                //Chekc if the pathpart exits in the translationLevel
                if (translationLevel[pathPart]) {
                    //set the translationlevel to the found level and repeat (till the deepest part)
                    translationLevel = translationLevel[pathPart];
                }
            }
            //Check if translationLevel is an string, if not it can mean no all the parts are found in de tranlation object
            if (typeof translationLevel === 'string' || translationLevel instanceof String) {
                return translationLevel;
            }
            //nothing found return '', so the script doesn't break
            return '';

        }

    }
})