如何在 OpenERP7 中翻译一个简单的 RML 报告字符串?

How to translate a simple string of a RML report in OpenERP7?

我制作了一个修改现有 RML 报告的模块。它只是修改 RML 文件(没有 Python 更改)。

我安装了该模块,然后就可以打印我的新报告了。但是,当我想导出 .pot 文件进行翻译时,它是空的。 不知道为什么,最后我不得不手动做翻译文件。

现在这些术语翻译得很好,除了一个。下一句:

<para style="terp_default_8">[[ (o.comment and format(o.comment)) or "Please, indicate the invoice number on the concept of income" ]]</para>

我将它添加到我的翻译文件中 (es.po),与其他有效的条款完全一样:

#. module: customized_reports_03
#: report:account.invoice.custom:0
msgid "Please, indicate the invoice number on the concept of income"
msgstr "Por favor, indique el número de factura en el concepto del ingreso"

我加载了翻译并更新了好几次,但是这句话没有被翻译。

为什么?可能是因为运算符 or?

最后,我意识到翻译文件无法识别您在 [[ ]] 之间编写的字符串。要解决这个问题,您必须找到一种方法来通过代码实现相同的行为,其中您的字符串不在双括号中。

在我的例子中,问题是这样解决的:

<para style="terp_default_8">[[ (o.comment and format(o.comment)) or removeParentNode('para') ]]</para>
<para style="terp_default_8">Please, indicate the invoice number on the concept of income[[ not o.comment and '.' or removeParentNode('para') ]]</para>