【问题标题】:Translation of database with poedit and zend translate用 poedit 和 zend translate 翻译数据库
【发布时间】:2013-05-13 05:32:03
【问题描述】:

Poedit 不会自动识别数据库中表格的内容。 什么是获得 poedit 识别的表格内容的最佳方法,以便在 zend 中进行翻译。我希望它自动完成....我必须从数据库中创建一个 xml 文件吗?

【问题讨论】:

    标签: doctrine-orm zend-framework2 zend-translate poedit


    【解决方案1】:

    您不应该使用 poedit 翻译数据库内容。您将在数据库中执行此操作。简短的回答:不幸的是,您想要的无法实现。

    你可以翻译“固定”字符串,如果你想翻译变量、常量或数据库值,你必须通过文字字符串翻译来做到这一点,以防 poedit 必须扫描它们:

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

    如果您与 Translation 对象有 1:n 关系会更容易。然后视图将从用户生成的内容中提取翻译:

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

    Gedmo 学说扩展中提供了最后一种可能性的示例:https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-14
      • 2016-02-07
      • 1970-01-01
      • 2016-01-10
      • 1970-01-01
      • 2018-08-06
      • 2011-08-18
      • 1970-01-01
      相关资源
      最近更新 更多