Home ยป Php ยป php – multilingual Content managed website (CMS) using zend framework

php – multilingual Content managed website (CMS) using zend framework

Posted by: admin July 12, 2020 Leave a comment

Questions:

Although I find quite a lot resources related to this question but none of them is precisely giving the answer to a Multilingual CMS using Zend Framework.

There are many zend translate adapters available in zend framwork. But the one (zend sql adapter), which is most need for database(mysql) driven websites, is not yet released.

For those multilingual websites, which are not database driven, contents can be placed in files (xml, mo, or any other) and one of the zend translate adapter is used to process the contents to display the correct language.

How we will deal with database driven multilingual website? Previously we were habit of using php with well-designed multilingual database keeping each article (page) in table with every required translation. If we will do the same by using zend framework, would that be over kill or slow website? We still make use of zend cache to make it faster, but we won’t able to take the advantage of zend translate. Later, when the zend translate adapter for sql will be available, would that be easy to switch that multi-lingual content managed system by using zend translate.

Has anyone tried this? What could be the pros and corns?

Another solution could be keeping our well design multilingual database and generate xml based language files on every change admin make using GUI in admin area. And then use one of zend translate adapter to handle these xml files. I guess that could be overkill, killing a bird with cannon ๐Ÿ™‚

When I am talking about placing the whole page’s content in database. It can include some html tags such as b, span, br, p etc. How well the zend translate can deal contents with html tags in it?

If someone already has implemented this before, what could be the best way to deal with Multi-lingual content managed website using zend framework.

Any expert opinion!

How to&Answers:

There are many zend translate adapters available in zend framwork. But the one (zend sql adapter), which is most need for database(mysql) driven websites, is not yet released.

For those multilingual websites, which are not database driven, contents can be placed in files (xml, mo, or any other) and one of the zend translate adapter is used to process the contents to display the correct language.

These are wrong assumptions. It is not said, that DB driven application needs to use DB driven translate system. You can easily use static-files system.

How we will deal with database driven multilingual website? Previously we were habit of using php with well-designed multilingual database keeping each article (page) in table with every required translation.

I think that you are a little bit mistaken – I understand that you would like to use Translate for the dynamic content of your page (articles). Translate is rather designed to internationalize the views – the static content. I mean things like login or register or welcome text, etc. And these really should be in the files (consider files a static cache) rather than in the DB, because of huge load it would make (DB should be cached anyway). The articles stored in the DB is a different thing, and what you want to achieve is multilangual page content. You can handle that easily without Translate (remember, Translate is good for views!), simply add a country/language flag to your tables and retrieve suitable (filtered for given language) data through your model. It is really straightforward and it doesn’t need any backend for translation.

I am not sure how Translate works, but I can assume that it checks the language and then loads whole translation file and stores it in script memory as a collection (or simple associative array) just to provide quick and robust translation mechanism (notice, that it wouldn’t need to call a DB or a file for every given key, because all of them would be in the memory). Keeping the whole pages, articles this way wouldn’t make sense at all, mainly because you need only 1-2 articles per page (why waste memory then?) and sometimes a hundreds of localized view strings (so you don’t want to make a call to a DB or file for each of them)

Another solution could be keeping our well design multilingual database and generate xml based language files on every change admin make using GUI in admin area. And then use one of zend translate adapter to handle these xml files. I guess that could be overkill, killing a bird with cannon ๐Ÿ™‚

If talking about translations for a static content – it really is very common solution: keeping the translations in the DB for easy access/change and generating the XML/CSV/whatever files when change occurs.

When I am talking about placing the whole page’s content in database. It can include some html tags such as b, span, br, p etc. How well the zend translate can deal contents with html tags in it?

It would probably deal good, but still, you are thinking about dynamic content. Static content should be formatted inside the view. So, dead end I guess.

Bottom line: Using Translate for all of that you mentioned, it would be killing a bird with a cannon ๐Ÿ™‚