React js and Laravel Localization strings?
You want to convert your translation files into JSON and use a client side translation function.
For example, image you generated something like this:
var translations = {"en":{"stream":{"counter":"counter"}}};
You could then write trans like this:
function trans(key){
var keys = key.split(".");
var lang = navigator.language.split("-");
return lang.concat(keys).reduce(function(o, k){
var next = o[k];
if (!next) {
console.error('No translation found for ' + key, new Error().stack);
return {};
}
else {
return next;
}
}, translations);
}
And in your components, just use
<div>{trans('stream.counter')}</div>