Simple localization support for elegant jsblocks "Better MV-ish" framework.
Do not expect much from this extension, use as is or improve and send me a pull request :-)
- Automatically downloads locale files when needed.
- Uses message as translation key. By default it accepts language as English.
- Can replace parameters in message.
- Caches loaded json lang file.
- Uses observables for messages, so dynamically renders new message when language changes.
<script type="text/javascript" src="vendor/jsblocks.I18n/jsblocks.I18n.js"></script>
locales/tr.json
:
{
"locale": "tr",
"data": {
"Song no {no} is playing now.": "Şimdi {no} nolu şarkı çalınıyor."
}
}
blocks.I18.init({
lang: 'tr'
});
<h1>{{ __('Song no {no} is playing now.', { no: 1 }) }}</h1>
console.log(__('Song no {no} is playing now.', { no: 1 }));