jigniter™

jQuery & CodeIgniter – Perfect combination for web application

Archive for the ‘i18n’ tag

A straightforward way to translate your language files in CodeIgniter

without comments

Months ago we discussed about different alternatives to add i18n support to CodeIgniter applications. On this opportunity we will show how easy is to maintain your language files using CodeIgniter Language File Translator by MrKirkland and Owen Christian.

Basically what you need to do is download the zip here and then unpack the files under appropriate location, as explained in the article.

Afterward, create your desired language files languages folder. For example, if you would like to use English and Spanish, let’s say you create these two files:

  • application/languages/spanish/general_lang.php
  • application/languages/english/general_lang.php

You’d need to load that general language file in your controller or the autoload.php config file, and then choose which of these files you will use as Master file. That means the file that you will keep updated every time and use as reference when synchronizing with the other slaves files.

Then, you’ll need to run the new controller that was unpacked by pointing your browser to index.php/translator

You will be guided through the translator interface that will take care of your language strings under master and slave files. So, go to your slave files and translate each value.

In case any key in your slave file is not present under your master file, then you will see a mismatch error message warning about that behavior.

For non-english speakers: If you plan to use a different Master file rather than English, you can. In theory you’d need to edit the config file under /application/config/translator.php , but my last attempt did not work in version 0.5.1, For example, if I’d like to use Spanish as Master language instead of English, then I needed to edit the variable used in controllers/translator.php under line #87:


var $masterLang = 'spanish';

For more information, we strongly recommend to read the author’s article.

Written byadmin

January 12th, 2010 at 7:22 pm

CodeIgniter in Spanish Language

without comments

CodeIgniter has been translated to many international languages, not only the User Guide but also the messages and errors strings in its language packs.

For example, you can find Spanish translations for your CodeIgniter applications, here. [Make sure to download the right version, ie: 1.7.2]

The next step once you unpack the .zip is to copy the files into your language directory that usually is located under /system/languages so it will read /system/languages/spanish

Then, to use Spanish messages in your applications you’ll need to chaneg the default language setting in /application/config/config.php under line $config['language']

Written byadmin

January 11th, 2010 at 1:14 pm

Posted inSnippets Ideas

Tagged with , ,

Internationalization i18n in CodeIgniter

without comments

Developing web applications with i18n support is easier with the help of a PHP framework. CodeIgniter has many libraries and helpers that makes the life easier for developers that require i18n support in their applications.

Here are some libraries and articles that may help you to figure how to create i18n web applications:

Using the Language Class & Helper

The Language class provided in CodeIgniter may be the first place to check out. It supports an easy way load language files.

In addition, the Language helper assists you while working with language files. It simply provides a lang() helper function instead of calling $this->lang->item() each time.

I’d strongly recommend the Internationalization Views i18n Wiki page. That article will guide you how to add i18n support in views, controllers and configuration files. You can also review the Internationalization category in that Wiki in order to find more information regarding to i18n approaches.

Using a library

Internationalization (i18n) library for CodeIgniter is a library that makes possible to easily change between languages by adding the language code in the URL.

For example, you may be able to use the following URL to switch between languages:

  • domain.com/en/controller
  • domain.com/fr/controller

The following diagram (taken from Maestric website) illustrates the way this library works.

Written byadmin

July 16th, 2009 at 2:02 pm

Posted inTutorials

Tagged with ,