Skip to content

Language Redirect Extension

yeah edited this page Aug 24, 2010 · 2 revisions

Radiant currently lacks full multi-lingual support, but it does have a nice extension for directing visitors to sections of the site that are in the language that their browser requests. It’s called the “Language Redirect” extension.

You’ll need to install the Language Redirect extension: See Language Redirect Extension. From the root of your Radiant project run:

./script/extension install language_redirect

(If this fails see the manual installation instructions)

Then restart your application server.

Assuming your Web site has the following structure:

Site Root: /
|
+- English Home Page: /en/
|
+- Italian Home Page: /it/
|
+- Japanese Home Page: /ja/
|
+- etc...

You can use the “Language Redirect” extension to automatically send a redirect to the appropriate language subsection of the site, when a user hits the site root. Simply:

  1. Set your site root’s Page Type to “Language Redirect”.
  2. Create a page part on the site root called “config”.
  3. Put the following in the “config” part:
en: /en/
ja: /ja/
it: /it/
*: /en/

The configuration is in key/value format, where the language is specified on the left side of the colon and the URL for that language is specified on the right side of the colon. In this case if the browser requests English content (en) they will be redirected to the “/en/” folder. If the browser requests Italian content, they will be redirected to the “/it/” folder. And so on… The last key/value pair uses “*” for the language. This tells the “Language Redirect” extension to redirect to the “/en/” folder if the browser requests a language that doesn’t match any of the languages that have been defined in the “config” part.

Additional instructions can be found in the source.

Question:

Any reason why you have to specify the path for /en/ twice? It seems it would be enough to specify ja, it and * so as not to repeat oneself.

Answer:

No reason at all. You are welcome to only specify /ja/ and star /en/.

Alternative

If you don’t want to replicate all your pages and stay a little more DRY, you could also check out the Multilingual Pages Extension.

Clone this wiki locally