xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.87k stars 776 forks source link

qt.ts规则应该指定lupdate的参考目录 #5311

Closed jingkaimori closed 2 months ago

jingkaimori commented 2 months ago

Xmake 版本

xmake v2.9.3+HEAD.a5da06f37

操作系统版本和架构

Windows 10 22H2

描述问题

目前lupdate会生成以下形式的命令行,其中 locale\locale_ru.ts 是项目中翻译文件的路径。

lupdate.exe -no-obsolete -ts locale\locale_ru.ts

由于未指定参考目录,lupdate无法识别翻译文件中源代码的相对路径:

    <message>
        <location filename="../src/gui/AboutDialog.cpp" line="37"/>
        <source>About</source>
        <translation>关于MidiEditor</translation>
    </message>

导致所有的翻译条目都被视作过时条目而被删除。

lupdate.exe -no-obsolete -ts locale\locale_ru.ts
Updating 'locale/locale_ru.ts'...
    Found 0 source text(s) (0 new and 0 already existing)
    Removed 650 obsolete entries

期待的结果

将当前的工程路径或者脚本路径添加到lupdate的参考目录输出中,从而使得lupdate可以定位翻译文件中的相对路径。 期望的输出

lupdate.exe .\ -ts .\locale\locale_zh.ts
Scanning directory '.\'...
./src/midi/MidiInput.cpp:50: Class 'MidiInput' lacks Q_OBJECT macro
./src/midi/MidiOutput.cpp:55: Class 'MidiOutput' lacks Q_OBJECT macro       
Updating 'locale/locale_zh.ts'...
    Found 650 source text(s) (0 new and 650 already existing)

工程配置


target("translation") do
    set_kind("phony")
    add_packages({
        "qt5widgets"
    })
    add_rules("qt.ts")
    add_files("locale/*.ts")
    after_build(function (target) 
        os.cp(path.join(target:targetdir(), "*.qm"), path.join(os.scriptdir(), "locale"))
    end)
end

附加信息和错误日志

暂无

Issues-translate-bot commented 2 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: qt.ts rule should specify the reference directory of lupdate

Xmake version

xmake v2.9.3+HEAD.a5da06f37

Operating system version and architecture

Windows 10 22H2

Describe the problem

Currently lupdate will generate a command line in the following form, where locale\locale_ru.ts is the path to the translation file in the project.

lupdate.exe -no-obsolete -ts locale\locale_ru.ts

lupdate cannot recognize the relative path to the source code in the translation file because the reference directory is not specified:

    <message>
        <location filename="../src/gui/AboutDialog.cpp" line="37"/>
        <source>About</source>
        <translation>About MidiEditor</translation>
    </message>

As a result, all translation entries are considered obsolete and deleted.

lupdate.exe -no-obsolete -ts locale\locale_ru.ts
Updating 'locale/locale_ru.ts'...
    Found 0 source text(s) (0 new and 0 already existing)
    Removed 650 obsolete entries

Expected results

Add the current project path or script path to lupdate's reference directory output, so that lupdate can locate the relative path in the translation file. desired output

lupdate.exe .\ -ts .\locale\locale_zh.ts
Scanning directory '.\'...
./src/midi/MidiInput.cpp:50: Class 'MidiInput' lacks Q_OBJECT macro
./src/midi/MidiOutput.cpp:55: Class 'MidiOutput' lacks Q_OBJECT macro
Updating 'locale/locale_zh.ts'...
    Found 650 source text(s) (0 new and 650 already existing)

Project configuration


target("translation") do
    set_kind("phony")
    add_packages({
        "qt5widgets"
    })
    add_rules("qt.ts")
    add_files("locale/*.ts")
    after_build(function (target)
        os.cp(path.join(target:targetdir(), "*.qm"), path.join(os.scriptdir(), "locale"))
    end)
end

Additional information and error logs

No

jingkaimori commented 2 months ago

当前的lupdate的参考目录是从add_files添加的其他代码的目录推断出来的,这就导致ts文件和cpp文件耦合在一个target下,不可能单独调整ts的构建顺序。

Issues-translate-bot commented 2 months ago

Bot detected the issue body's language is not English, translate it automatically.


The current lupdate reference directory is inferred from the directories of other codes added by add_files. This causes the ts file and the cpp file to be coupled under the same target, making it impossible to adjust the build order of ts independently.