Using the language class

One of the most useful features of CodeIgniter is its language class and support. It allows you to store content and set that content to belong to various languages; it is then possible to switch between languages to display different text in the same place holders in the view files. It's really easy to set up and this is how you do it.

Getting ready

A little information about language files. You'll need to know the rules for naming them. Language files are stored at /path/to/codeigniter/application/system/language/[language_name]/.

Where [language_name] is the name of the language you wish to support. So, for example, if you want to support English, French, and German you will create three file names:

  • /path/to/codeigniter/application/language/english/en_lang.php ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.