v3 init push

This commit is contained in:
2026-09-03 18:28:33 +02:00
parent f719cb2989
commit 361cf93562
112 changed files with 8760 additions and 4873 deletions
+25
View File
@@ -0,0 +1,25 @@
export default class Lang {
constructor({translations = {}, prefix = '', locale = 'en'} = {}) {
this.translations = translations;
this.prefix = prefix;
this.locale = locale;
}
get(sLangId = '', params = []) {
if(sLangId === '') return '';
const asParams = Array.isArray(params) ? params : [params];
if(Object.prototype.hasOwnProperty.call(this.translations, sLangId)) {
let sText = this.translations[sLangId];
asParams.forEach((sParam, iIndex) => {
sText = sText.replace('$' + iIndex, sParam);
});
return sText;
}
console.warn('Missing translation:', sLangId);
return sLangId;
}
}