Simple I18N library for PHP

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/robotdance/i18n

v0.0.8 2016-06-28 16:25 UTC

This package is not auto-updated.

Last update: 2025-09-28 01:49:13 UTC


README

Code Climate Test Coverage Issue Count Build Status

PHP-I18n is a simple I18N and L10n library.

Setup

PHP-I18n uses Composer as dependency management tool.

$ composer install

Use

Create a folder called config/locales at your app/module, and put your locale YAML files there. (an example of valid YAML file can found in the source). Then call I18n::t, in one of the ways below.

Simple key/value lookup

$translated = I18n::t('example_message');

Locale override

$translated = I18n::t('example_message', [], 'pt_BR');

Injecting arguments

$translated = I18n::t('hello_message', ['user' => 'Bob']); // 'Hello Bob'

Note about formatting currently the library does not apply formatting to arguments.

Localisation

Create a section 'l10n' on your locale file and follow the source standards.

$value = I18n::l(true);    // 'verdadeiro'
$value = I18n::l(123.45); // '123,45'

Running tests

$ ./bin/phpunit

Contribute

Fork, write tests, code, submit pull request. Coverage must remains at 100%.

References

PHP the right way Fixing PHP errors automatically PHP SPL Exceptions What exception subclasses are buit in