languagepicker This will allow you to create language picker in second

  1. Introduction
  2. Requirements
  3. Installation/Usage
  4. Little lesson in intenalization:


This is a simple widget to pick a language from your internalizations available! It automatically searches your /application/messages/ for available translations and put it in the list, and user can pick it. This little CPortel, so it is easy to make it look cooler via css or even little flags for languages ;-)


Ability to follow instructions, and have Yii installed ;-)


Download the extension, and put it in your extensions directory. I'm sure most of you extend CController...

it uses CPhpMessageSource

so in your main config should be

'messages' => array(
       	 	'class' => 'CPhpMessageSource'

Actually it is the default, so you can omit it ...

Put inside CController::init() , or in beforeAction method


In your view, put:

$this->widget('ext.LanguagePicker.ELanguagePicker', array(

And you're done...

If you don't have any directories inside messages/ just create some, for example : ru, he, en etc. and you will the the list created

feel free to customize it, improve it, and don't forget to share your improvements ;-)

Additional links

Make sure you check out my theme picker also

Little lesson in intenalization:

If you new to Yii maybe you don't know how to use internalization: Create 2 directories under APPPATH/messages/ lang1 and lang2

than, create there a file app.php

put inside lang1/app.php the following:

return array(
	'abc' => ''this is first language translation',

put inside lang2/app.php the following:

return array(
	'abc' => 'this is second language translation',

Now insert in your view

echo Yii::t('app', 'abc');

And try to play with language selector, and you will understand in seconds how it works

even more info

you can add for example in main.php

'sourceLanguage' => 'en',
'language' => 'ru',

language will be the default translation, and you must know that translation happens only if sourceLanguage differs from language

7 0
1 448 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: dckurushin
Created on: Sep 25, 2011
Last updated: 12 years ago


show all

Related Extensions