O'Reilly logo

CodeIgniter 2 Cookbook by Rob Foster

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the language class – switching language on the go

Once you have developed your site to accommodate multiple languages, you'll obviously want to allow people to switch between them. For example, to switch from English to French, or French to German, or whatever region or language you're developing for. This can be handled in several ways, but in this example, we're going to use the CodeIgniter Session class to swap from one language to another.

Getting ready

We're going to use the Session class to store the user's language preference, which means, we'll need to use CodeIgniter sessions. This will require some configuration.

We'll be editing the following files:

  • path/to/codeigniter/application/config/config.php
  • path/to/codeigniter/application/config/database.php ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required