Skip to content

Instantly share code, notes, and snippets.

@azazqadir
Created February 20, 2018 13:00
Show Gist options
  • Save azazqadir/477b947b4d87600338b0da151a378c6d to your computer and use it in GitHub Desktop.
Save azazqadir/477b947b4d87600338b0da151a378c6d to your computer and use it in GitHub Desktop.
Developing a Multilingual Site in CodeIgniter

Specify Default Language and Language Options

Go to application/config folder and open config.php. Add the following line to specify the website’s default language.

$config['language']  = 'english';
$config['language']  = 'english';

Now to create the language options, of to application/language folder and create separate subfolders for each language. Next, in each subfolder, create a file with the suffix _lang. For instance, if you wish to offer a file named information.php in English and German languages, use the following structure:

Application→ language → English → information_lang.php

Application→ language → German → information_lang.php

Set up Language Files

Within the language file, information_lang.php, add every line of text to a $lang array in the following format:

$lang['language_key'] = 'type your message';
$lang['language_key'] = 'type your message';

For instance, the entry for the text line, “Type message in German” in the file in the German language folder would look like:

$lang['welcome_message'] = 'Type message in German';
$lang['welcome_message'] = 'Type message in German';

Read full article at: https://www.cloudways.com/blog/multi-language-codeigniter/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment