Poedit 不会自动识别数据库中表格的内容。 获得 poedit 识别的表格内容以在 zend 中进行翻译的最佳方法是什么?我希望它自动完成....我是否必须从数据库创建一个 xml 文件?
最佳答案
您不应该使用 poedit 翻译数据库内容。您将在数据库中执行此操作。简短的回答:不幸的是,您想要的无法实现。
你可以翻译“固定”字符串,如果你想翻译变量、常量或数据库值,你必须通过文字字符串翻译来做到这一点,以防 poedit 必须扫描它们:
<?php
if($var === 'foo') {
echo $this->translate('foo');
} else {
echo $this->translate('bar');
}
如果您与 Translation
对象具有 1:n 关系,那就更容易了。然后 View 将从用户生成的内容中提取翻译:
<?php
echo $foo->Translation['en-us']->bar;
Gedmo 学说扩展中提供了最后一种可能性的示例:https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md
关于doctrine-orm - 使用 poedit 和 zend translate 翻译数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16619356/