joedixon / laravel-translation

Translation management for your Laravel application.
MIT License
694 stars 230 forks source link

how to achieve dynamic fallback_locale set #255

Open noumansarwarr opened 1 year ago

noumansarwarr commented 1 year ago

I'm trying to achieve the following result:

The user of an app can fill entities in two languages (the app is in two languages) If one language is not available the other one should be taken.

The fallback_locale setting allows me to set one as a fallback, i.e.

I have a user model with HasTranslations trait

public $translatable = ['fname', 'lname', 'short_info', 'address', 'detail'];

If the user signup in English local and then changes to Arabic it will show the user name as set in English (en) during sign up because fallback_locale is set to English (en) but when the user signup Arabic(ar) locale and then change to English(en) it will not show the user name as set during signup in the Arabic(ar) locale because fallback_locale is set to en.

Is there a way to do this by setting fallback_locale dynamically?

Regards,