Multilingual Mastery with Laravel
Thanks for watching my talk at Laravel Live 2024. I hope it inspired you to make inclusive, localised applications that can be used by people all over the world.
Here's some links to resources that I mentioned in the talk:
-
This is a package I developed to allow you to use the localisation syntax commonly seen in frontend frameworks, in Laravel.
-
Spatie's laravel-translatable package allows you to localise your database driven content.
-
Laravel's Localisation documentation
Laravel's documentation is a great place to re-cap most of the string externalisation concepts discussed.
-
The
Number
class is a great way to format numbers in a locale-aware way. -
When you're formatting a date in Carbon, you can use the
isoFormat
method to format a date in a locale-aware way, using one of the many macro-formats available here. -
The Accept-Language header provides us with the user's preferred language, as determined by the operating system.
-
The HasLocalePreference contract allows you to easily send notifications to a user, using their persisted preferred locale.
-
Lokalise, Transifex and Crowdin
These tools give you a dashboard to manage your translation files, and allow you purchase translations too. They come with a GitHub integration too, so changes to translation files get raised as a PR.
-
This VSCode extension will make your development journey so much easier. You'll see your translations inline, plus you'll get a warning if you're missing a translation key.
-
This extension features the same functionality as mentioned previously, but for Jetbrains IDEs.
A couple more points,
-
If you're using Laravel Vapor to deploy your application, you may need to take some additional steps to support multiple locales. I've written a blog post that steps you through what you need to do, and explains why.
-
One thing I didn't touch on here is RTL. This is a whole other topic, but it's something you'll need to think about if you need to add language support for a right-to-left language, like Arabic or Hebrew. I'm hoping to provide you with some content on this in the near future.
-
I'm super passionate about this topic, and I want to help you all on your localisation journey. So if you have any questions or feedback, please feel free to reach out to me on Pinkary or any of my other socials linked there.