Astrotomic / laravel-translatable

A Laravel package for multilingual models
https://docs.astrotomic.info/laravel-translatable/
MIT License
1.23k stars 155 forks source link

Fallback Locale as per the model column #283

Closed davymaish closed 1 year ago

davymaish commented 2 years ago

Hi thank you for the wonderful package.

Is there a way in which i can change the fallback locale of translation as per the model instead of a global configuration.

My application is used by different users using different locale. Example default fallback locale in the configuration is 'en'. A post is created by a writer in 'es' locale. Another user reads the post in 'fr' locale. The application displays nothing to the reader as both 'fr' (the users locale) and 'en' (the fallback locale ) are not saved in the database. I would like to set the fallback locale to be set as per the post in which the fallback locae to be the original locale the post was written in. How can i set the fallback locale to be dependent to the model?

My idea was to have a column on the Post Model to hold the actual locale in which the post was created and point the fallback locale to point to that column in the event both reader user locale and config fallback locale are not define in the database.

Thank you in advance

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days

Gummibeer commented 1 year ago

You can use the "find any translation" mechanism by setting fallback_locale to null. https://docs.astrotomic.info/laravel-translatable/package/fallback-locale#app-wide

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days