Download the PHP package popphp/pop-i18n without Composer
On this page you can find all versions of the php package popphp/pop-i18n. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download popphp/pop-i18n
More information about popphp/pop-i18n
Files in popphp/pop-i18n
Package pop-i18n
Short Description Pop I18n Component for Pop PHP Framework
License BSD-3-Clause
Homepage http://www.popphp.org/
Informations about the package pop-i18n
pop-i18n
- Overview
- Install
- Quickstart
- Advanced
Overview
pop-i18n
is a component for internationalization and localization. It provides the features for
translating and managing different languages and locales that may be required for an application.
It also provides for parameters to be injected into the text for personalization.
pop-i18n
is a component of the Pop PHP Framework.
Top
Install
Install pop-i18n
using Composer.
composer require popphp/pop-i18n
Or, require it in your composer.json file
"require": {
"popphp/pop-i18n" : "^4.0.0"
}
Top
Quickstart
First, you will have to create your language and locale files. The accepted formats are either XML or JSON:
fr.xml
fr.json
From there, you can create your I18n object and give it the folder with the language files in it. It will auto-detect which file to load based on the language passed.
Bonjour, mon nom est Nick. Je aime programmer PHP.
Alternatively, you can directly echo the string out like this:
You can set the language and locale when you instantiate the I18n object like above,
or if you prefer, you can set it in your application as a constant POP_LANG
and
the I18n object will look for that as well. The default is en_US
.
Top
Advanced
The pop-i18n
component comes with the functionality to assist you in generating your
required language files. Knowing the time and possibly money required to translate
your application's text into multiple languages, the component can help with assembling
the language files once you have the content.
You can give it arrays of data to generate complete files:
Also, if you have a source text file and an output text file with a 1:1 line-by-line ratio, then you can create the language files in fragment set and merge them as needed. An example of a 1:1 ratio source-to-output text files:
source/en.txt | output/de.txt |
---|---|
This field is required. | Dieses Feld ist erforderlich. |
Please enter your name. | Bitte geben Sie Ihren Namen ein. |
So then, you can do this:
And merge the fragments into a main language file.
All versions of pop-i18n with dependencies
ext-json Version *
ext-simplexml Version *
ext-libxml Version *