because blade cache the views, it means that getting the locale b4 rendering is useless as it will remain the same unless you clear the view cache each time the user switch the language.
this patch has removed the config file
updated the readme
moved the js file to assets/vendor instead of assets/js/vendor to follow packages usual pattern.
instead of using translations.auth.failed.en it would be translations('auth.failed') and you would get the trans according to current local automatically.
i've tried
var data = $data
window.translations = function(item) {
return data[item][lang]
}
but it doesnt work because it should be interpreted as data.auth.failed not data.'auth.failed' as one key "any help is appreciated"
add a command to flush the view cache when a new locale is added.
add a command to save I18n.js along with the data into assets/js/vendor/i18n so now we dont need any extra steps to get the translation to work.
instead of translator.trans('auth.failed'); use trans('auth.failed'); so the usage is the same as laravel and also the same whether we use the blade directive or the js import.
this is based on https://github.com/thepinecode/i18n/issues/2
because blade cache the views, it means that getting the locale b4 rendering is useless as it will remain the same unless you clear the view cache each time the user switch the language.
assets/vendor
instead ofassets/js/vendor
to follow packages usual pattern.in patch # 2
translations.auth.failed.en
it would betranslations('auth.failed')
and you would get the trans according to current local automatically.i've tried
but it doesnt work because it should be interpreted as
data.auth.failed
notdata.'auth.failed'
as one key "any help is appreciated"I18n.js
along with the data intoassets/js/vendor/i18n
so now we dont need any extra steps to get the translation to work.translator.trans('auth.failed');
usetrans('auth.failed');
so the usage is the same as laravel and also the same whether we use the blade directive or the js import.