Waavi / translation

Better translation management for Laravel
MIT License
360 stars 167 forks source link

Overriding current locale to fetch localized model attributes in specific language #163

Closed NaLogo closed 4 years ago

NaLogo commented 4 years ago

How do I fetch translated attributes of a model in a specific language which is not the currently selected locale?

Example: A user is currently browsing the site in English and they want to use a custom form to enter new/updated non-English translations for a model. How do I provide the current, non-English attributes?

NaLogo commented 4 years ago

I'm gonna close this as I have found a solution.

In case you're wondering: I have extended the Translatable trait (by using it in another trait which I'm then using for my models) to allow easy fetching of an attribute in a specific language by making use of the Translation repository in conjunction with translationCodeFor().