12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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'
- },
- 'Connections':{
- 'en':'Connections',
- 'fr':'Connections',
- 'bra':'Conexões',
- 'lat':'Hospites'
- },
- }
- }
|