2017 © Pedro Peláez
 

library intl

easy internationalization support for PHP

image

crodas/intl

easy internationalization support for PHP

  • Friday, August 29, 2014
  • by crodas
  • Repository
  • 1 Watchers
  • 0 Stars
  • 181 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

crodas/intl

Easy internationalization support for PHP, (*1)

It aims to be a drop-in replacement for gettext., (*2)

Setup

It can be installed with composer, (*3)

composer require crodas/intl:dev-master

Concepts

crodas/intl at run time provides a few functions (__, _e and _ if gettext in not installed) to translate text. It also provides a generator that walks throughtout the project and extract all texts it can find and generates a template file., (*4)

That template needs to be copied in order to create new locales or languages. You can run this process as many time as you'd like, the template file and all locale files are going to be updated (but we never override its content)., (*5)

Whenever you update your locale files you would need to compile it in order to load efficiently from your PHP app., (*6)

TODO: add demos, (*7)

Using

In order to use crodas/intl, it needs to be initialized as follows:, (*8)

require "vendor/autoload.php";

crodas\Intl::init("/tmp/language.php", $locale);

It takes two arguments, the first is the compiled locale and the second is the language to use., (*9)

It is possible to switch to another locale at any time by doing:, (*10)

crodas\Intl::setLanguage($locale);

Then you can call to __("Hello") and __("Hello %s, welcome"), they will be replaced with the correct locale or the default content will be print if we can't the locale file or the sentence to translate, pretty much like gettext works., (*11)

The Versions

29/08 2014

dev-master

9999999-dev

easy internationalization support for PHP

  Sources   Download

BSD-4-Clause

The Requires

 

by César D. Rodas