andres-ml/cakephp-i18n 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

andres-ml/cakephp-i18n

Composer 安装命令:

composer require andres-ml/cakephp-i18n

包简介

I18n plugin for CakePHP

README 文档

README

Allows setting a default domain for translations.

Before:

__('members'); // outputs members
__d('hospitals', 'members'); // outputs patients
__n('Record', 'Records', 2); // outputs Record or Records
__dn('hospitals', 'Record', 'Records', 2); // outputs Visit or Visits
__x('written communication', 'He read the first letter'); // Adds additional context for use during translation
__dx('hospitals', 'eye chart viewing', 'He read the first letter'); // Adds additional context for use during translation
__xn('character', 'Spy', 'Spies', 2); // Adds additional context for use during translation
__dxn('hospitals', 'to see', 'Spy', 'Spies', 2); // Adds additional context for use during translation

With plugin:

use Aml\I18n\I18n;

__('members');                      // outputs members
__t('members');                     // outputs members
__n('Record', 'Records', 2);        // outputs Records
__tn('Record', 'Records', 1);       // outputs Record

I18n::domain('hospitals');
__('members');                      // still outputs members
__t('members');                     // outputs patients
__n('Record', 'Records', 2);        // outputs Visits
__tn('Record', 'Records', 1);       // outputs Visit

Installation

You can install this plugin into your CakePHP application using composer.

composer require andres-ml/cakephp-i18n

Usage

Automatically load the plugin by running bin/cake plugin load Aml/I18n

Manually load the plugin in src/Application.php bootstrap() function by adding the following line

$this->addPlugin('Aml/I18n');

Wherever you would use __(), you can now use __t().

Wherever you would use __n(), you can now use __tn().

Wherever you would use __x(), you can now use __tx().

Wherever you would use __xn(), you can now use __txn().

Remember to create a domain.po file next to each default.po file for each domain you want to support. (https://book.cakephp.org/4.0/en/core-libraries/internationalization-and-localization.html#language-files)

To automatically generate the default.pot base file:

bin/cake aml/I18n.i18n extract

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-01-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固