import { i18n, Util } from '../index';
export class Translate {
    constructor() {
        this.t = {};
        this.i18n = i18n;
        this.defaultLanguage = 'en-US';
        this.supportedLanguages = [
            'en-US',
            'nl-NL'
        ];
        this.translations = {};
        Object.keys(i18n).forEach((k) => {
            this.supportedLanguages.push(k);
        });
        this.translations = Util.copy(i18n);
        this.translations['nl-NL'] = Util.copy(this.translations['nl']);
        this.translations['en-US'] = Util.copy(this.translations['en']);
        this.translations['en-BE'] = Util.copy(this.translations['en']);
        this.translations['en_BE'] = Util.copy(this.translations['en']);
        this.use(this.defaultLanguage);
    }
    use(language) {
        this.language = language;
        if (!this.translations[language]) {
            // todo: http fetch json
        }
        this.t = this.translations[language];
    }
    get(string) {
        return this.instant(string);
    }
    instant(string) {
        let translation;
        let t = this.t;
        Object.keys(t).forEach((k) => {
            if (k === string) {
                translation = t[k];
            }
        });
        if (translation) {
            return translation;
        }
        else {
            return string;
        }
    }
}
//# sourceMappingURL=translate.js.map