1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/multi-link/add_language.pri
2018-05-26 11:03:48 +08:00

172 lines
5.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#---------------------------------------------------------------------
#应用程序语言翻译qmake文件。通过qmake与编译调用。
#如果需要增加某国语言add_language(...)即可。
#---------------------------------------------------------------------
#$$APP_SOURCE_PWD on mac TRANSLATIONS error, why?
#APP_SOURCE_PWD=$${PWD}
#用户在macOS下下使用PWD符号
##############################################################################
#内部函数
##############################################################################
defineReplace(get_lupdate_language){
#pro file
propath = $$1
!isEmpty(2): error("get_lupdate_language(propath) requires one argument")
isEmpty(1): error("get_lupdate_language(propath) requires one argument")
command =
command = lupdate $${propath}
#message($${command})
return ($${command})
}
defineReplace(get_lrelease_language){
filepath = $$1
filename = $$2
!isEmpty(3): error("get_lrelease_language(filepath, filename) requires two argument")
isEmpty(2): error("get_lrelease_language(filepath, filename) requires two argument")
command =
command = lrelease $${filepath}/$${filename}.ts -qm $${filepath}/$${filename}.qm
#message($${command})
return ($${command})
}
##############################################################################
#公开函数
##############################################################################
defineTest(lupdate_language){
#pro file
propath = $$1
!isEmpty(2): error("lupdate_language(propath) requires one argument")
isEmpty(1): error("lupdate_language(propath) requires one argument")
command =
command += $$get_lupdate_language($${propath})
!isEmpty(QMAKE_PRE_LINK):QMAKE_PRE_LINK+=$$CMD_SEP
QMAKE_PRE_LINK += $${command}
export(QMAKE_PRE_LINK)
return (true)
}
#输入.ts的 路径 和 文件名(不带后缀)
defineTest(lrelease_language){
filepath = $$1
filename = $$2
!isEmpty(3): error("lrelease_language(filepath, filename) requires two argument")
isEmpty(2): error("lrelease_language(filepath, filename) requires two argument")
command =
command += $$get_lrelease_language($${filepath}, $${filename})
!isEmpty(QMAKE_PRE_LINK):QMAKE_PRE_LINK+=$$CMD_SEP
QMAKE_PRE_LINK += $${command}
export(QMAKE_PRE_LINK)
return (true)
}
#输入pro全路径 .ts路径 .ts文件名(不带后缀,相当于需要添加的语言类型)
#注意:.ts路径必要使用$${PWD}符号
defineTest(add_language){
propath = $$1
filepath = $$2
filename = $$3
isEmpty(3)|!isEmpty(4): error("add_language(propath, filepath, filename) requires three argument")
#翻译语言起效
TRANSLATIONS += $${filepath}/$${filename}.ts
export(TRANSLATIONS)
command =
command += $$get_lupdate_language($${propath}) $$CMD_SEP
command += $$get_lrelease_language($${filepath}, $${filename})
!isEmpty(QMAKE_PRE_LINK):QMAKE_PRE_LINK+=$$CMD_SEP
QMAKE_PRE_LINK += $${command}
export(QMAKE_PRE_LINK)
return (1)
}
defineTest(add_zh_CN_en_US){
propath = $$1
filepath = $$2
isEmpty(2)|!isEmpty(3): error("add_zh_CN_en_US(propath, filepath) requires two argument")
#翻译语言起效
TRANSLATIONS += $${filepath}/zh_CN.ts $${filepath}/en_US.ts
export(TRANSLATIONS)
command =
command += $$get_lupdate_language($${propath}) $$CMD_SEP
command += $$get_lrelease_language($${filepath}, zh_CN) $$CMD_SEP
command += $$get_lrelease_language($${filepath}, en_US)
!isEmpty(QMAKE_PRE_LINK):QMAKE_PRE_LINK+=$$CMD_SEP
QMAKE_PRE_LINK += $${command}
export(QMAKE_PRE_LINK)
return (1)
}
############################################################################################################################################################
#以下翻译过程qmake的时候执行
#以下函数设计思路正常但是qmake执行堵死请勿使用无奈。
############################################################################################################################################################
#输入pro的完整路径
defineTest(qmake_lupdate_language){
#pro file
propath = $$1
!isEmpty(2): error("qmake_lupdate_language(propath) requires one argument")
isEmpty(1): error("qmake_lupdate_language(propath) requires one argument")
command = $$get_lupdate_language($${propath})
system_errcode($${command}): return (true)
return (false)
}
#输入.ts的 路径 和 文件名(不带后缀)
defineTest(qmake_lrelease_language){
filepath = $$1
filename = $$2
!isEmpty(3): error("qmake_lrelease_language(filepath, filename) requires two argument")
isEmpty(2): error("qmake_lrelease_language(filepath, filename) requires two argument")
command = $$get_lrelease_language($${filepath}, $${filename})
system_errcode($${command}): return (true)
return (false)
}
defineTest(add_qmake_language){
propath = $$1
filepath = $$2
filename = $$3
isEmpty(3)|!isEmpty(4): error("add_qmake_language(propath, filepath, filename) requires three argument")
#翻译语言起效
TRANSLATIONS += $${filepath}/$${filename}.ts
export(TRANSLATIONS)
qmake_lupdate_language($${propath})
qmake_lrelease_language($${filepath}, $${filename})
return (1)
}
#专门为中英文定义的
defineTest(add_qmake_zh_CN_en_US){
propath = $$1
filepath = $$2
isEmpty(2)|!isEmpty(3): error("add_qmake_zh_CN_en_US(propath, filepath) requires two argument")
#翻译语言起效
TRANSLATIONS += $${filepath}/zh_CN.ts $${filepath}/en_US.ts
export(TRANSLATIONS)
qmake_lupdate_language($${propath})
qmake_lrelease_language($${filepath}, zh_CN)
qmake_lrelease_language($${filepath}, en_US)
return (1)
}