Translation of database with poedit and zend translate

独自空忆成欢 提交于 2019-12-10 10:08:56

问题


Poedit does not automatically recognise the content of a table in a database. What is the best way to get the content of a table recognized by poedit for its translation in zend. I would like it to be done automatically....do I have to create an xml file from the database ?


回答1:


You should not translate database contents with poedit. You would do that inside the database. The short answer: what you want cannot be achieved, unfortunately.

You can translate "fixed" strings and if you want to get variables, constant or database values translated, you have to do that via literal string translations, in the case poedit has to scan them:

<?php
if($var === 'foo') {
    echo $this->translate('foo');
} else {
    echo $this->translate('bar');
}

It's easier if you have a 1:n relation with a Translation object. The view would then pull the translation from user generated content:

<?php
echo $foo->Translation['en-us']->bar;

An example of this last possibility is provided in the Gedmo doctrine extension: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md



来源:https://stackoverflow.com/questions/16619356/translation-of-database-with-poedit-and-zend-translate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!