Courses

Multi-Language Laravel 11: All You Need to Know

Final Thoughts: Course Conclusion

Summary of this lesson:
- Overview of localization approaches in Laravel
- Recommended packages for different translation needs
- Highlight key localization strategies
- Suggest combining packages for comprehensive solution
- Provide guidance on translating text, routes, models, and more

There's no one-size-fits-all solution for localization. It can be really complex and include everything in the application or it can be as simple as just translating static text.

I'll try to summarize the main points of this course:

  • Translating text. You can install a package to move translations to a database/Excel sheet but that is not mandatory.
  • Translating validation/form attributes. You just use what Laravel provides.
  • Translating routes. I would recommend the https://github.com/mcamara/laravel-localization package to save a lot of time and effort.
  • Localizing dates. You can use Carbon localization feature.
  • Localizing currencies. You can use PHP's NumberFormatter class.
  • Translating DB Models. Not required to have a package but both spatie/laravel-translatable and astrotomic/laravel-translatable can be really beneficial.

You can also use a combination packages. For example:

I hope this course gave you a good overview of the most important packages and how to use them.

If there are any questions or suggestions, feel free to write a comment below.

avatar

Hello there, This was a great tutorial but there is something missing that I don't know how to implement: update a slug from a model in the language switcher.

English URL site.com/post/[english-slug] French URL site.com/article/french-slug]

When using the locale switcher, it should redirect to the french slug otherwise it would get a 404 error with the current switcher: site.com/article/[english-slug] (instead of site.com/article/[french-slug])

How could you implement this?

Thanks! Vincent

avatar

Hey, this one is a bit tricky to implement. Since there are slugs that are changing, you need to:

  1. Check if there is any slugs/string parameters on url (not part of url, but dynamic parts)
  2. Figure out to what it belongs
  3. Retrieve new slug
  4. Redirect to the new slug

And this quickly becomes a bigger deal than you might think, with a lot of fallbacks/checks needed. I can't go deep into specifics here due to the size of this project (in order for it to be done correctly), sorry! Hope the general idea/direction helps you

avatar
You can use Markdown
avatar

great course, thanks. would be good also to add how to translate text in js files

avatar

We have an article about that:

//post/laravel-and-vuejs-translations-with-i18n-plugin

avatar
You can use Markdown
avatar

Thank you very much. A good selection with real examples.

avatar
You can use Markdown
avatar
You can use Markdown