Projects - Translate Package


Living in a country with four official languages has forced me to recognize the importance of localization. While this site is currently only available in two languages - English and French - I am making sure that no translation functionality is hardcoded and that it is all easily expandable. Laravel has decent built in localization but provides no easy way to localize based on subdomain or on a per request basis. Since I was using the same code for multiple projects, I consolidated my localization code into a Laravel package. The package is mostly just a middleware which performs the following two steps:

  1. If the subdomain corresponds to a language it sets the app locale accordingly.
  2. If there is a session variable containing the language it sets it to that.

It also includes a route to set the session variable to a language, which allows the user to translate each page without changing the subdomain,

Last Updated: 2017-01-29 12:10

More Information

Detailed information on the package is available here.