// Create NetR namespace if it doesn't exist
if (typeof (NetR) === 'undefined') {
    var NetR = {};
}

NetR.Translation = function() {
    this.init();
};

NetR.Translation.prototype = {
    currentLanguage: 'sv',
    strings: {
        'sv': {
            'image': 'Bild',
            'of': 'av',
            'print_page': 'Skriv ut sidan'
        },
        'no': {
            'image': 'Bilde',
            'of': 'av',
            'print_page': 'Skriv ut siden'
        },
        'da': {
            'image': 'Billede',
            'of': 'af',
            'print_page': 'Udskriv denne side'
        },
        'fi': {
            'image': 'Kuva',
            'of': '/',
            'print_page': 'Tulosta sivu'
        },
        'en': {
            'image': 'Image',
            'of': 'of',
            'print_page': 'Print this page'
        }
    },
    translate: function(str) {
        var translated = str;
        if (typeof (this.strings[this.currentLanguage]) != 'undefined' &&
            typeof (this.strings[this.currentLanguage][str]) != 'undefined') {
            translated = this.strings[this.currentLanguage][str];
        }
        return translated;
    },
    init: function() {
        this.currentLanguage = document.getElementsByTagName('html')[0].getAttribute('lang');
    }
};

function _(text) {
    if (typeof (NetR.t) === 'undefined') {
        NetR.t = new NetR.Translation();
    }
    return NetR.t.translate(text);
}

