robotdance / i18n
Simple I18N library for PHP
Requires
- php: >=5.3.2
- robotdance/php-app-config: 0.0.9
- robotdance/php-arguments: 0.0.4
- symfony/yaml: ~3.1
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: 4.8.24
This package is not auto-updated.
Last update: 2025-01-18 22:03:35 UTC
README
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