[SOLVED] Translating QLineEdit context menu
-
I would like to translate default QLineEdit context menu. I've found a similar topic qt-project.org/forums/viewthread/22203. I know that I should use QApplication::installTranslator() but I don't know which translation file I should load or I should create a new file?
-
Hi,
"Here":http://doc.qt.io/qt-5/i18n-source-translation.html you have the starting point to create translatable code as well as setup your project (create translation files, load them etc.).
-
I loaded the file which contains translations of these strings and now it works properly. But I would like to add as well another file with my own strings. I created .qm file and tried to load it but it doesn't work. Is it possible to load several translation files?
-
Yes it is, just load them all at your application startup. IIRC you can also combine several of them in only one file.
How did you generate your custom file ?
-
I added this line to .pro file:
@TRANSLATIONS += file_name_pl.ts@Then I run Tools > External > Linguist > Update translations (lupdate) which generated .ts file. I opened this file with Linguist and added translations of strings.
Then I run lupdate and Tools > External > Linguist > Compile translations (lrelease) which generated .qm file. I also added these lines to .cpp file and run the application:
@QTranslator Translator;
Translator.load("file_name_pl");
app.installTranslator(&Translator);@ -
You are giving it a relative path, did you copy that file in the same folder as the application ?
-
When using a relative path you must ensure that everything is copied in the right place i.e. the application folder.