[SOLVED] [Qt Translations] using += lrelease and += embed_translations
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[Qt Translations] using += lrelease and += embed_translations
Good morning.
I do not understand the documentation of the qmake config-variables, nor the use of QM_FILES_RESOURCE_PREFIX, cannot see, how those translations under /usr/share/Qt[n]/translations are found by the respective applications, and have no clue about how I get my *.qm files read by my own application.
Here are the pertinent excerpts from my project. These are not working.
I have moved the .qm files all over the place but the only way to make them available to the executable, had been to store them along the program, in the same directory. Each modification of my *.pro file had been followed by make distclean;qmake.
Anyway, I cannot see that QM_FILES_RESOURCE_PREFIX were honored anywhere, at least not in the generated Makefile.
For 15 years, I have not considered it necessary to produce translations for this program; I may just as well continue this way.
The only translation mechanism that satisfies me today, is my own, for the Ruby-language. No big deal, I would have said... but I am probably wrong.
Thank you for any hints.
Cheerio.
Edit: In the Qt-forum several responses are given to similar questions. Apart from imitating the code-examples, given there, and then to hope for the best, I see no way of taking benefit from these discussions, either. The procedures are illogical and the descriptions cryptic. I will not code something that I do not understand.
Last edited by Michael Uplawski; 03-26-2023 at 01:20 PM.
Reason: Ornitho ... orthographix and some grammatix, too. Typing with 9¾ fingers.
Side-note: as I can imagine xslt-processing the *.ts files into a C++ header-file, can you imagine problems with the idea?
Side-note 2: YAML. Do you have experience with a YAML library for C++ ? This could be easier to integrate than a header-file, but may slow down the execution, as I cannot conditionally instantiate locale-specific translators.., I guess.
Last edited by Michael Uplawski; 03-26-2023 at 01:27 PM.
Reason: yaml
I have not advanced any further, but consent to discuss the examples. 1) the directory “languages” is a top level object in the project? Like in
Code:
--------------
/home/user/projects/pdfviewer
src
languages
lib
(...)
---------------
2) :resources, from your second code example, is what and where?
3) There is no translation embedded in your examples. I ignore, thus, the detail which should help me advance with my own project. Maybe comment the code in this way, I do not yet get it.
More questions to follow.
Last edited by Michael Uplawski; 03-27-2023 at 02:00 AM.
Reason: finger bandaged.
Nothing I did not know, myself. Maybe someone knows what this file is supposed to do and why it does not help me.
THE GENERATIONS TO COME, HEAR ME Edit: qmake_qmake_qm_files.qrc is a default resource file, when nothing else is set (nothing *.qrc in the project file).
And: Solved
The ominous path in the second argument to Translator.load() is a resource path. You can define your own, but if you choose to embed translations in your program, this path does not need to point at an existing directory: It depends on the content of the *.qrc file:
Code:
qresource prefix="i18n">
This is from the automatically generated default resource file, when none is named in the project-file. The prefix “i18n” will serve as parameter to Translator.load():
Code:
[[maybe_unused]] bool isso = translator.load(QString("upsslideshow_") + locale, ":i18n");
The remainder of the configuration is made only in the project-file *.pro:
You need *no* Prefixes other than i18n in the main.cpp (where the QTranslator is instantiated) and no file-paths whatsoever. lrelease will compile *.qm files to te directory “.qm” that is referenced in the default resource-file and the prefix i18n is enough to find it there.
Run qmake and make. Additional *.cpp- and *.h files will be generated, containing the translations, then compiled and linked in the executable.
Big Mess, but it works now.
Big mess in the documentation and all the discussions that I have found,
Last edited by Michael Uplawski; 03-27-2023 at 09:01 AM.
Reason: syntax, update
Thank you for the blog link.while searching online for essay examples, I find this website where I can view several essay writing samples that aid in the completion of my essay assignments. If you are also looking for essay assignments, you can visit this website.
Last edited by DellaKirkpatrick; 04-21-2023 at 05:44 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.