Skip to content

zend framework 2 - translation on steroids - some thoughts

The following lines are loud thoughts so far. I will give it a try and implement a fitting module for that. But so far, it is really just an idea.

You started your zend framework 2 translation by using the official translation guide for zend framework 2 and it was running fine with some words.
But then, you started working agile, using git flow and doing this by using multiple branches. It turned out that you will get a lot of merge conflicts (also on git) with your translation files if something had changed on your develop branch and on your feature branch. This results in high maintenance costs.

So what to do?
Here is my basic idea. Decouple the translation file from your code.

  • First of all, you want to shift from file based to database based translation.
  • After that, you reduce the usage of the database and add caching

Shift from file based to database based translation

  • Create a database with the name like "translation"
  • Inside this database, create a table called "keys" with the columns "id", "key_name" (or "name") and "created_at"
  • Inside this database, create as many "language" tables as you want
  • Each "language" table has the following columns "id", "key_id", "key_value" (or "value") and "created_at"
  • After that, create a basic import that inserts all names in the table "keys" and all values in the fitting "language" table
  • Next, you have to create an "translation adminstration" frontend to maintain the existing "translation keys" with its fitting "translation values" according to the right language.
  • Finally, you have to overwrite the existing view helper with your own, database driven, one

Reduce the usage of the database and add caching

Translate to de es fr it pt ja

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

The author does not allow comments to this entry

Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Markdown format allowed
Form options