1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-24 23:37:51 +01:00
Maicol Battistini ceb854bbb3
feat(i18n): Aggiunto nuovo sistema di traduzioni backend e frontend
Il nuovo sistema si basa sul sistema nativo di Laravel. Le traduzioni e la lingua dell'utente vengono passati a JS (mithril) tramite Inertia. C'è anche una route per modificare la lingua.
2021-08-03 19:17:43 +02:00

23 lines
468 B
JavaScript
Vendored

import Component from './Component';
/**
* The `Page` component
*
* @abstract
*/
export default class Page extends Component {
page = JSON.parse($('#app').attr('data-page'));
__(key: string, replace: Object = {}) {
let translation = this.page.language[key]
? this.page.language[key]
: key;
Object.keys(replace).forEach((k: string) => {
translation = translation.replace(`:${k}`, replace[k]);
});
return translation;
}
}