cinghie/yii2-multilanguage

Multi Language support for Yii2 Framework.

Installs: 5 611

Dependents: 2

Suggesters: 0

Security: 0

Stars: 9

Watchers: 3

Forks: 7

Open Issues: 0

Type:yii2-extension

2.0.2 2018-10-10 22:17 UTC

This package is auto-updated.

Last update: 2024-12-09 11:07:04 UTC


README

License Latest Stable Version Latest Release Date Latest Commit Total Downloads

Multi Language support for Yii2 Framework based on this post on Official Forum:
http://www.yiiframework.com/forum/index.php/topic/56027-yii2-multilingual-website-url-rules/

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require cinghie/yii2-multilanguage "*"

or add this line to the require section of your composer.json file.

"cinghie/yii2-multilanguage": "*"

Configuration

Set in Configuration File:

// Language Settings
'language'   => 'en',
'sourceLanguage' => 'en_GB',

Make sure you have set the parameter 'language': the default language will be that

Set URL Manager in 'component' Configuration File:

// Url Manager
'urlManager' => [
    'class' => 'codemix\localeurls\UrlManager',
    'languages' => ['en', 'it', 'fr', 'de', 'es'], // List all supported languages here
    'enablePrettyUrl' => true,
    'showScriptName' => false,
],

Images

Copy the img folder from the project root to your web folders to see flag's images

Widgets

You can load the MultiLanguage Widget in the your view like this:

<?= MultiLanguageWidget::widget([
	'addCurrentLang' => true, // add current lang
	'calling_controller' => $this->context,
	'image_type'  => 'classic', // classic or rounded
	'link_home'   => true, // true or false
	'widget_type' => 'classic', // classic or selector
	'width'       => '28'
]); ?>

There are 4 params in the Widget:

  • Widget Type can be classic or selector
  • Image Type can be classic or rounded
  • Width in pixel of the flags
  • The Calling Controller (Do not Edit)

Changelog

  • Version 2.0.2 - Adding options to add current Lang on widgets
  • Version 2.0.1 - Adding Ca, Ch, In, Ne, Ru, Us flags
  • Version 2.0.0 - Refactoring project adding Yii2 Locale URLs: https://github.com/codemix/yii2-localeurls
  • Version 1.2.0 - Minor improvements
  • Version 1.1.2 - Fixing error to extends yii Widget problem
  • Version 1.1.1 - Update Copyright and license
  • Version 1.1.0 - Bug Fixed not home View
  • Version 1.0.0 - Initial Release