Laravel translation / multi-language support

  laravel, laravel-localization

I am using Laravel v8.1 and want to offer a multi language support. I already checked and thought to use spatie/laravel-translation-loader but from their documentation, it looks like it only support "short keys" and not "translation strings as keys", which is a deal breaker. Desired outcome is:

  • all translations stored inside DB (importing and exporting like barryvdh/laravel-translation-manager offers is also acceptable, but last option)
  • caching of translations, so it won’t call the database per each translated string
  • a HTML interface for editing those translations (which I can code)
  • grouping of translations (or dividing those into sections, so I would have "auth", "validation", "users", "dashboard", "clients")
  • using "translation strings as keys", since I do not want to make "short keys" per each text I want to translate (harder to read the code and much harder to maintain the translations)
  • fallback to default language if translation is not found

Plan is to use translation strings in .blade templates like normal text using __(''). In back-end, there would be an interface for a translation that would group the text into pre-determined groups, front-end would not care about those groups, only pulling the translated text based on "translation strings".

So, I want to use __('I love programming and it's great!') and NOT __('').

Source: Laravel

Leave a Reply