https://github.com/becklyn/javascript-translator
The JS implementation of Symfony's Translator.
https://github.com/becklyn/javascript-translator
Last synced: 3 months ago
JSON representation
The JS implementation of Symfony's Translator.
- Host: GitHub
- URL: https://github.com/becklyn/javascript-translator
- Owner: Becklyn
- License: bsd-3-clause
- Created: 2019-07-30T08:53:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-22T11:23:36.000Z (about 5 years ago)
- Last Synced: 2025-03-01T23:00:00.583Z (3 months ago)
- Language: TypeScript
- Size: 38.1 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
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](https://github.com/Becklyn/translations-bundle).Initialization
--------------For example like this (using `mojave`):
```js
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:
```js
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);
```