How to get all the fields translated in a given language from a model?
Drillan767 opened this issue · comments
Joseph Levarato commented
I have an Article model that has 3 translated fields, each of them can be translated to either english or french, french being the "fallback language".
I'm building a website that uses Inertia in the administration zone, and Blade in the visitor zone, and I can't find a way to "automatically" load all the translated fields in a given (or fallback) language, so I find myself having to do something like this:
this.article.lang = this.article.default_lang; // usually the fallback language, 'fr'
this.article.title = this.article.title[this.article.lang];
this.article.content = this.article.content[this.article.lang]
Is there a way to simplify this?
Thanks in advance
Freek Van der Herten commented
Hi, please create a discussion in the Q&A category for this. 👍