I recently had need to do some translations with ZF2, the current state of ZF2 means that you can only load translations from files so I decided to take this oppertunity to experiment with creating my own module for doing it.
DASPRiD had already had a bash at creating something for this but unfortunately it didn’t work, I was able to take the code and work with it to produce this module.
So first we fork or clone the ZendSkeleton Application and then checkout a new branch to work on
we edited the composer.json to get the latest version of ZF2 and also to fetch our G403Translation module
Then we get composer to install our modules for us
After that we set up our db and user and imported our SQL that’s in the README.md for the module Here we’re using custom table names, the default assumed within the module are zend_locale and zend_translate_message.
Then we set up the db connection within the code itself
this file is within config/autoload/ and also another file for setting up the translator, as with all configs this can be done in a module config or in the config/autoload/ directory in this example inside the autload config
We then insert some data into the tables
And we can see the change in our Zend Skeleton Application from to
To learn a bit about plurals read here.