language-picker This extension renders simple language picker

  1. Requirements
  2. Usage
  3. Translations
  4. Additional information
  5. Look
  6. Try out

This extension allows to change site language. I was using this extension earlier and I decided to make my own.

Requirements

  • Bootstrap (works with newest alpha version) - only if you choose buttons style
  • Yii 1.1
  • Enabled cookies

Usage

Just add this code to init() method in your main controller class (protected/components/Controller.php)

public function init()
{
	Yii::import('ext.LangPick.ELangPick'); 
	ELangPick::setLanguage();
	parent::init();
}

And in the place where you want to render Language Picker

<?php $this->widget('ext.LangPick.ELangPick', array()); ?>

And don't forget to set source language in (protected/config/main.php)

return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'Demo',
	...
    'sourceLanguage'=>'en',
	...

Translations

You have to create translations, which should be placed in messages folder

messages
	de	// folder
		strings.php	// translation file
	pl	// folder
		strings.php	// translation file

Each translation file should contain translation array

<?php

return array (
    'Home' => 'Główna',
    'About' => 'O stronie',
);

?>

finally, to use translations:

Yii::t('strings', 'Home')

For more info, please read manual.

Additional information

If you want to customize it

<?php $this->widget('ext.LangPick.ELangPick', array(
	'excludeFromList' => array('pl', 'en'),	// list of languages to exclude from list
	'pickerType' => 'buttons',          	// buttons, links, dropdown
	//'linksSeparator' => '<b> | </b>',   // if picker type is set to 'links'
	'buttonsSize' => 'mini',            	// mini, small, large
	'buttonsColor' => 'success',        	// primary, info, success, warning, danger, inverse
)); ?>

Look

Look

Try out

9 0
22 followers
2 094 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: lowlliet
Created on: Sep 8, 2012
Last updated: 11 years ago

Downloads

show all

Related Extensions