@becklyn/translator
v1.3.0
Published
The JS implementation of Symfony's Translator.
Downloads
11
Maintainers
Keywords
Readme
Symfony JavaScript Translator
This is a modern implementation of the JS translator to translate Symfony's translation messages. Best to be used with the translation bundle.
Initialization
For example like this (using mojave
):
import {initFromGlobalData} from "mojave/init";
import {Translator} from "@becklyn/translator";
let translator = initFromGlobalData("TranslatorInit", new Translator());
A manual way to wire it up to global data is like this:
function loadGlobalData (key, handler)
{
if (undefined === window[key])
{
return;
}
// replace global callback
window[key].init = (data) => handler.init(data);
// handle current data
handler.init(window[key].data);
}
let translator = new Translator();
loadGlobalData("TranslatorInit", translator);