Put the text to file in resources not in C++ code. Additional profit: you can edit the text in the HTML editor.
Put the text to file in resources not in C++ code. Additional profit: you can edit the text in the HTML editor.
Thank you! I don't really want to translate this large field, but I want all the strings in the application to be passed through tr(). I'll search how can I tr() the text from the resource file.
Could you details how to read the resource file? Store it as XML UTF-8, or as text? Read it line by line?
Something like this, if file name is thanks.txt (txt in UTF-8) and is located in main directory of resource file :Qt Code:
file.close();To copy to clipboard, switch view to plain text mode
Of course I'm talking about Qt resources.
lalesculiviu (9th March 2018)
Thank you! I learned some nice Qt code with this. But I think that lupdate will not extract the thanks.txt string correctly.
I do not think that adding such large text to QApplication::translate was a good idea. In my opinion, you should prepare separate txt files with the translated text and load the appropriate file.
I'll think about it. Thank you!
But maybe Qt code should care about these long strings for MSVC.
Note: I did not use directly the QApplication::translate. The file .\tmp\gui\ui_helpaboutform_template.h is generated automatically by Qt UIC, I only modify the file src/interface/helpaboutform_template.ui.
Bookmarks