aimeos / ai-zend2-i18n
Zend Framework 2 adapter for Aimeos web shops and e-commerce solutions
Installs: 6 254
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Type:aimeos-extension
Requires
- php: >=5.3.3
- aimeos/aimeos-core: 2018.10.*
- composer/installers: ^1.0
- zendframework/zend-i18n: ~2.3
- zendframework/zend-servicemanager: ~2.3
- dev-master
- 2018.10.x-dev
- 2018.10.1
- 2018.07.x-dev
- 2018.07.1
- 2018.04.x-dev
- 2018.04.1
- 2018.01.x-dev
- 2018.01.2
- 2018.01.1
- 2017.10.x-dev
- 2017.10.1
- 2017.07.x-dev
- 2017.07.2
- 2017.07.1
- 2017.04.x-dev
- 2017.04.1
- 2017.03.x-dev
- 2017.02.x-dev
- 2017.01.x-dev
- 2017.01.2
- 2017.01.1
- 2016.10.x-dev
- 2016.10.1
- 2016.07.x-dev
- 2016.07.2
- 2016.07.1
- 2016.04.x-dev
- 2016.04.1
- 2016.01.x-dev
- 2016.01.2
- 2016.01.1
- 2015.10.x-dev
- 2015.10.3
- 2015.10.2
- 2015.10.1
- 2015.07.x-dev
- 2015.07.1
- 2015.03.x-dev
- 2015.03.1
- 2015.03.0
- 2014.x-dev
This package is auto-updated.
Last update: 2019-02-20 20:03:27 UTC
README
Aimeos Zend2 I18n adapter
The Aimeos web shop components can integrate into almost any PHP application and uses the infrastructure of the application for building URLs, caching content, configuration settings, logging messages, session handling, sending e-mails or handling translations.
The ai-zend2-i18n extension integrates the Zend I18n component for translating messages into Aimeos. It's useful if the Aimeos translations should be available in your application.
Table of content
Installation
To allow the Aimeos web shop components to retrive translations for the used strings, you have to install the adapter first. As every Aimeos extension, the easiest way is to install it via composer. If you don't have composer installed yet, you can execute this string on the command line to download it:
php -r "readfile('https://getcomposer.org/installer');" | php -- --filename=composer
Add the ai-zend2-i18n extension to the "require" section of your composer.json
file:
"require": [
"aimeos/ai-zend2-i18n": "dev-master",
...
],
If you don't want to use the latest version, you can also install any release. The list of releases is available at Packagist. Afterwards you only need to execute the composer update command on the command line:
composer update
Setup
Now add the Zend I18n object to the Aimeos context, which you have to create to get the Aimeos components running:
$i18nPaths = $aimeos->getI18nPaths();
$i18n = new \MW_Translation_Zend2( $i18nPaths, 'gettext', 'en', array( 'disableNotices' => true ) );
$context->setI18n( array( 'en' => $i18n );
The $aimeos
object is an instance of the Aimeos
class from the core. The code above would only set up the translation for English but you can also set up several languages at once and pass them in the array to the setI18n()
method.
To speed up retrieving translated strings, you can wrap the translation object into the APC decorator before adding it to the context:
if( function_exists( 'apc_store' ) === true ) {
$i18n = new \MW_Translation_Decorator_APC( $i18n, 'myApcPrefix:' ) );
}
This would use the shared memory of the web server to store and retrieve the strings from there instead of the binary gettext "mo" files.
To overwrite translations by local ones you can furthermore added them on top:
$i18n = new \MW_Translation_Decorator_Memory( $i18n, array( /*...*/ ) );
All translations from the second parameter would be used instead of the ones from the gettext files. The format of the translations must be:
'<translation domain>' => array(
'<original singular>' => array('<singular translation>','<plural translation>'),
),
'client/html' => array(
'address' => array('Address','Addresses'),
),
License
The Aimeos ai-zend2-i18n extension is licensed under the terms of the LGPLv3 license and is available for free.