Mysql adapter for Zend_Translate
Asked Answered
C

3

5

I'm currently in the planning phase of a rather large project that I'll develop in the Zend Framework. One of the problems I'm facing is that the customers will want to translate not only the content but also the interface. I'm currently using gettext and poedit to manage my language files but this is not an option for the customer as they, for one, wont have FTP access to the site.

Hence, I'm thinking of a mysql back end with an interface in the front end for the customer to manage his own translations of the interface. There is however still no mysql adapater for Zend_Translate.

So, does anybody now of an adapter script for Zend_Translate so it can work with a mysql table? Or any arguments against using mysql and possible other solutions for this problem?

Canzona answered 8/6, 2010 at 8:4 Comment(0)
S
7

You could solve this problem on different ways:

Extend Zend_Translate_Adapter to create your own. All new adapters are only responsible from getting the translations out from the source. That is, you would need only to fetch the translations from the database. Look at other adapters and see how they are implemented.

Fetch the data from the database and pass it to Zend_Translate_Adapter_Array

Use Zend_Translate_Adapter_Csv or Ini. As there would be more reading the writing on the translations, this solution would cut down the number of queries to the database. When the client adds a new language or changes an existing one, simply write it to a file, not the database.

If you decide to go with the database adapter, maybe you could "tag" somehow the translations, so that on the home page you fetch only the translations for the home page, on the contact page only the translations for the contact page...

HTH!

Spiritualism answered 8/6, 2010 at 8:42 Comment(0)
M
3

Default Zend adapters handle caching well, so I'd stick to them, unless you really need database.

Instead storing the translation data in the database, you may directly operate on the translation files (e.g. po templates). This would be the best choice if you just needed to add (append to file) new translation strings.

You may use Zend_Translate's option to log untranslated messages (to file or any log adapter, including database), and then handle the logs, or even create listener translating the saved strings.

Missing answered 8/6, 2010 at 11:27 Comment(0)
B
0

Here's how: http://cloetensbrecht.be/zend_translate_mysql.html

Baloney answered 20/11, 2010 at 19:13 Comment(2)
Cheers mate! By now I'd written something similar myself.Canzona
think of a framework that dont supply native db translation helper. honour of Shame is not the right of cloetensbrencht, instead so called framesuck.Hypnotize

© 2022 - 2024 — McMap. All rights reserved.