修改源后翻译文件仍然有效? [英] Translation file still working after modifying the source?

查看:43
本文介绍了修改源后翻译文件仍然有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 .ts 文件的一部分,使用 pylupdate4 创建,如下所示:

A part of my .ts file, created with pylupdate4, looks like:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
    <name>Main</name>
    <message>
        <location filename="Main.py" line="2369"/>
        <source>Translate me to Ukululu</source>
        <translation type="unfinished"></translation>
    </message>

两个问题:

1:翻译位于 -标签之间,对吗?

1: The translation comes between the <translation>-tags, right?

2:翻译似乎需要主文件中要插入翻译的行(line=2369").但是每次我修改代码时,行都会改变.因此,我是否必须创建一个新的翻译文件,我必须再次在标签之间手动插入所有(未更改的)翻译?这似乎是一项疯狂的工作.如果我错了,请纠正我或解释一下,它是如何工作的(更好)!

2: The translation seems to need the line in the main file where the translation is to be inserted ("line=2369"). But everytime I modify the code, the lines change. Hence, do I have to create a new translation file, where I have to manually insert all the (unchanged) translations between the tags again? This seems like a crazy amount of work. Correct me if I am wrong or please explain, how it works (better)!

推荐答案

你说得对.原始文本位于标签 中,而译文位于标签 中.翻译完成后,属性 type="unfinished" 也将被删除.

You are right. The original text comes in the tag <source> while the translation comes in the tag <translation>. When the translation is finished the attribute type="unfinished" will also be removed.

通常您不会手动编辑 ts 文件,而是使用 QtLinguist 工具.我从不手动编辑它们,因为 QtLinguist 非常易于使用...

Usually you don't edit ts files manually but you use the QtLinguist tool. I never edit them by hand, since QtLinguist is very easy to use...

无论如何,当您更改源代码时,您只需运行

In any case, when you change the source code, you simply run

pylupdate4 your_project.pro

这将更新对 ts 文件中各行的所有引用,并保持已完成的翻译.即使您将它们移动到不同的源文件,它也可以更新翻译.

This will update all the references to the lines in the ts file, and it will keep the translation already finished. It is smart enough to update the translations even if you move them to a different source file.

您可以在此处获取更多信息

You can get further information here

http://pyqt.sourceforge.net/Docs/PyQt4/i18n.html

http://qt-project.org/doc/qt-4.8/linguist-manager.html

希望能帮到你

这篇关于修改源后翻译文件仍然有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆