Search

CodeIgniter  Internationalization

The Multi-Language feature is necessary for the modern web application. This feature is used for the purpose of internationalization.

  • CodeIgniter system folder, you will find a language sub-directory containing a set of language files for the English idiom.
  • The files in this directory (system/language/English/) define the regular messages, error messages, and other generally output

You can create or incorporate your own language files, as needed, in order to provide application-specific output, or to provide translations of the core messages into other languages. These translations or additional messages would go inside your application/language/ directory, with separate sub-directories for each idiom (for instance, ‘Hindi’ or ‘English’ or ‘Urdu’)

Internationalization

The CodeIgniter Language class  is meant to provide an easy and lightweight way to support multiple languages in your application. It is not meant to be a full implementation of what is commonly called internationalization and localization.

Using the Language Class

Creating Language Files

Language files must be named with _lang.php as the filename extension. For example, let’s say you want to create a file containing error messages. You might name it: error_lang.php

Within the file you will assign each line of text to an array called $lang with this prototype:

$lang['success_message'] = 'Your data have succefully saved !';

Loading A Language File

In order to fetch a line from a particular file you must load the file first. Loading a CodeIgniter language file is done with the following code:

$this->lang->load('filename', 'language');

Stack Overlode is optimized Tutorials and examples for learning and training. Examples might be simplified to improve reading and learning and understand. Tutorials and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using Stack Overlode, you agree to have read and accepted our terms of use, cookie and privacy policy.