定制 motion/yii2-language-provider 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

motion/yii2-language-provider

最新稳定版本:2.1.0

Composer 安装命令:

composer require motion/yii2-language-provider

包简介

This package provides interface for language provider for Yii2 Framework

README 文档

README

This package provides interface for language provider for accessing application languages from any storage for Yii2 Framework. It's allows to you create multi-language modules for using in Yii2 based application. As example of integration to module you can see yii2-email-template extension.

Latest Stable Version Monthly Downloads Total Downloads Build Status Scrutinizer Code Quality

From the box you can use:

If you want to create your implementation of language provider you should implement interface motion\i18n\LanguageProviderInterface.

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require motion/yii2-language-provider 

or add

"motion/yii2-language-provider": "~2.1" 

to the require section of your composer.json.

Usage

Config language provider

Option Description Type Default
languages Should contains list of application languages. array []
defaultLanguage Should contains default application language. array []

Example

$config = [ 'languages' => [ [ 'label' => 'English', 'locale' => 'en', ], [ 'label' => 'Ukrainian', 'locale' => 'uk', ], [ 'label' => 'Russian', 'locale' => 'ru', ], ], 'defaultLanguage' => [ 'label' => 'English', 'locale' => 'en', ], ]; $provider = new \motion\i18n\ConfigLanguageProvider($config); $provider->getLanguages(); // returns list of languages $provider->getDefaultLanguage(); // returns default language $provider->getLanguageLabel('en'); // returns language label by locale (`English`)

Database language provider

Option Description Type Default
db Database connection instance. string, array, \yii\db\Connection db
tableName Name of language entity in database. string language
localeField Name of locale field in language entity. string locale
labelField Name of label field in language entity. string label
defaultField Name of field in table with default language flag. string is_default

Example

$config = [ 'db' => 'secondDb', 'labelField' => 'title', ]; $provider = new \motion\i18n\DbLanguageProvider($config); $provider->getLanguages(); // returns list of languages $provider->getDefaultLanguage(); // returns default language $provider->getLanguageLabel('uk'); // returns language label by locale

Tests

You can run tests with composer command

$ composer test 

or using following command

$ codecept build && codecept run 

Licence

License

This project is released under the terms of the BSD-3-Clause license.

Copyright (c) 2017-2018, Motion Web Production

统计信息

  • 总下载量: 19.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固