0

I have a Qt application that I want to translate in several languages. I create the .ts files but some source code is visible (those containing the text to translate of course). I would like to prevent this source code from being displayed, available in generated .ts files because I will sent them to other people to do the translation and I don't want them to see the source code (work confidentiality). So is it possible to generate .ts file without the source code appearing in it? Thanks.

4

1 回答 1

0

不是这种情况。复制到 .ts 文件的唯一“源代码”是直接在使用tr()宏之前以冒号开头的注释,如下面的代码所示。该<source>元素包含要翻译的字符串而不是源代码!

如您所见,没有源代码进入该.ts文件。我不认为有人真的可以声称包含文件名和行号就等于泄漏源代码,如果这就是你想说的话。

如果您确实将源代码放入.ts文件中,那么您在 lupdate 中发现了一个错误,您应该创建一个最小的测试用例并编辑您的问题以演示在通过 lupdate 运行时泄漏到.ts文件中的源代码.

#include <QString>
#include <QObject>

class Foo : public QObject {
  Q_OBJECT
  void a() {
    //: comment
    QString text = tr("foo");
  }
};

此代码生成以下.ts文件:

<!DOCTYPE TS>
<TS version="2.0">
<context>
    <name>Foo</name>
    <message>
        <location filename="q.cpp" line="8"/>
        <source>foo</source>
        <extracomment>comment</extracomment>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>
于 2013-09-26T02:25:59.757 回答