开发者

Qt original value of translated(internationalized) text

开发者 https://www.devze.com 2023-01-28 12:40 出处:网络
ok, here is my problem. I have a multilingual app. I translate the ui with lupdate and lrelease. I have some options the user can edit, and he edits them from the input selection dialog. The values a

ok, here is my problem. I have a multilingual app. I translate the ui with lupdate and lrelease.

I have some options the user can edit, and he edits them from the input selection dialog. The values are for example "Quality" and "Speed".

Now, I'd like to replace those values with their translations开发者_开发问答.

Later, when I check the values of the option, I want to use only the original value. For instance: I have to check if value == "Speed", but if the language is not set to English, I will not have the "Speed" value in the selection dialog, but the string with the translation of "Speed".

How can I access the default (English) value from code, if the ui is already set to another language?


If I'm understanding correctly, you can just set the English value as a constant and refer to it.

const char* kEnglishKey = "Speed";
...
if (value == tr(kEnglishKey)) {
  ...
  DoSomeThingWith(kEnglishKey);
}

tr is a runtime, not compile-time, operation.

0

精彩评论

暂无评论...
验证码 换一张
取 消