Language translation? Passing data from the server to the client?
Laravel and Vuejs - how do I handle language translations ?
Can any one suggest me the best way to handle language translations from laravel to vue ?
Thanks
@Ruffles Sorry I did not make it clear
Yes language translations . I would prefer to use laravel localisation method , if there is any proper way . But if its not a good method I would go with vue i18n plugins
I think it depends largely on what you want to do with the translations. If you want them to be interactive client side, then youre probably going to have to send data to the server and fetch the translations. If the client side translations are static, you can just send them in your components. I usually bundle all my translations up and send them in a json array in my components.
I just extracted my bundle thing out to a package: https://github.com/zachleigh/laravel-lang-bundler
Its still a little rough, but it works perfectly.
I've used Lang.get('reminder.user') from the package https://github.com/andywer/laravel-js-localization
Also added some trans filter:
Vue.filter('trans', (key) => {
return Lang.get(key);
});
@zachleigh I'm currently using static translations via lang folder/json file.
However, i would also like to add translations to eloquent models For example
Article (id, category_id, created_at, updated_at) Article_translations(id, article_id, locale_code, content)
I want this to work along with the main translations that i have created with vue i18n so that when i select ES the spanish article is produced on the component. I use {{ $t('name" }} to fetch translations. How to fetch translations from db and get it synced with language picker
Please or to participate in this conversation.