定制 wvdongen/cakephp-i18njs 二次开发

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

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

wvdongen/cakephp-i18njs

Composer 安装命令:

composer require wvdongen/cakephp-i18njs

包简介

Translate JavaScript strings like Drupal 8.

README 文档

README

A CakePHP 2.x plugin to translate JavaScript strings. The JavaScript functions and methods to fetch the translation strings are taken from Drupal 8.

How to include

  • Put the files in APP/Plugin/I18nJs
  • Make sure you have CakePlugin::load('I18nJs') or CakePlugin::loadAll() in your bootstrap
  • Include the JavaScript lib to your HTML $this->Html->script('/i18n_js/js/18n_js')
  • Add generated JavaScript translation file $this->Html->script('/js/Locale/i18n_js.' . $this->Session->read('Config.language'))

JavaScript functions

I18nJs.t(str, args, options)

Translate strings to the page language or a given language.

Examples:

I18nJs.t('This string needs transalation');
I18nJs.t('Welcome @name', {'@name': 'Wouter'});

I18nJs.t(count, singular, plural, args, options)

Format a string containing a count of items.

Examples:

Drupal.formatPlural(count, '@name has 1 site.', '@name has @count sites.', {'@name': personName});
Drupal.formatPlural(count, '1 comment', '@count comments');

Generate .pot file

Console/cake I18nJs.i18n_js extract_js

This will parse all the javascript translation functions from your .js and .ctp files. This will create the file App/Locale/i18n_js.pot.

Create JavaScript translation file

Make sure your translations are located in App/Locale/<language>/LC_MESSAGES/i18n_js.po.

Console/cake I18nJs.i18n_js create_js

This will create JavaScript file(s) as App/webroot/js/Locale/i18n_js.<language>.js.

This fill should be added to your HTML. Add for example the following to your default.ctp file:

echo $this->Html->script('/js/Locale/i18n_js.' . $this->Session->read('Config.language'));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固