Putting the locale in your URL


A fundamental rule of the web is that a given URL should always return the same content, regardless of which user is looking at it.

This means we can't do any funny business such as deciding a logged in user should see our site in French, where a none-logged-in user sees the site in German.

Instead, we must put "things" in to the URL to ensure the content is always the same... on that URL. And for translations we do this by putting in the locale.

So whereas before this you may have had mysite.com/about - after following this process, you will have mysite.com/en/about, or mysite.com/fr/about - and each URL will display the content in the given language.

It's all about the locale.

Code For This Course

Get the code for this course.

Episodes