2017 © Pedro PelĂĄez
 

cakephp-plugin cakephp-i18n

I18n plugin for CakePHP

image

andres-ml/cakephp-i18n

I18n plugin for CakePHP

  • Wednesday, January 18, 2017
  • by andres-ml
  • Repository
  • 0 Watchers
  • 0 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 9 % Grown

The README.md

I18n plugin for CakePHP

Allows setting a default domain for translations., (*1)

Before:, (*2)

__('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:, (*3)

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., (*4)

composer require andres-ml/cakephp-i18n

Usage

Automatically load the plugin by running bin/cake plugin load Aml/I18n, (*5)

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

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

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

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

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

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

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), (*11)

To automatically generate the default.pot base file:, (*12)

bin/cake aml/I18n.i18n extract

The Versions

18/01 2017

dev-master

9999999-dev https://github.com/andres-ml/cakephp-i18n

I18n plugin for CakePHP

  Sources   Download

The Requires

 

The Development Requires

cakephp i18n

10/01 2017

dev-beta

dev-beta https://github.com/andres-ml/cakephp-i18n

I18n plugin for CakePHP

  Sources   Download

The Requires

 

The Development Requires

cakephp i18n