
module.exports = {
  t(key){
    if(this.locales[key]){
      if(this.lang){
        if(this.locales[key][this.lang]){
          return this.locales[key][this.lang];// key for current language
        }else{this.log(`Key "${key}" does not exists for language ${this.lang}`);}
      }else if(this.locales[key][this.fallback]){
        return this.locales[key][this.fallback];// key for fallback language
      }else{this.log(`Key "${key}" does not exists for fallback language ${this.fallback}`);}
    }else{this.log(`Key "${key}" does not exists.`);}
    return key;// if nothing else retrn key it self
  },
  setLang(l){
    this.lang = l
  },
  log(msg){
    console.log(`i18n : ${msg}`);
  },
  fallback:'en',
  lang: null,
  locales:{
    'Parts':{
      'en':'Parts',
      'fr':'Parties',
      'bra':'Peças',
      'lat':'Pars'
    },
    'Mode':{
      'en':'Mode',
      'fr':'Mode',
      'bra':'Modo',
      'lat':'Modus'
    },
    'Language':{
      'en':'Language',
      'fr':'Langue',
      'bra':'Língua',
      'lat':'Lingua'
    },
    'Text':{
      'en':'Text',
      'fr':'Texte',
      'bra':'Texto',
      'lat':'Illud'
    },
    'Conexions':{
      'en':'Conexions',
      'fr':'Connections',
      'bra':'Conexões',
      'lat':'Hospites'
    },
  }
}
