Plugin translation
I want to translate a plugin for another language. Maybe 8-9 months ago someone told me about QTLinquist to translate a plugin. I can't get it to work. If you know about QTlinguist, then you know you first have to create a translation file (ts file) then open it up in Linguist. I can't get the lupdate program (used to create translation file) to work. I keep getting this error message in the CMD window: "Some files have been ignored due to missing qml/javascript support". The translation file is created, but it is blank, so Linguist will not open it.
I googled the error and it took me to github. The last comment on the linguist github site was 5 years ago for the same error message. Has QTlinguist been deprecated? Someone responding on github to the error message mentions recompiling linguist after changing some code and it now works. I don't wanna do that and I don't know how do to that.
Any advice?
Comments
Check the the batch convert plugin, https://musescore.org/en/project/batch-convert
It comes with translations and scripts (actually batch files) to generated the .ts files from the plugin and the .qm file from the .ts files
In reply to Check the the batch convert… by Jojo-Schmitz
Thanks. When I open the plugin (inside of Musescore) here is what comes up (see attachment). I don't see qml or ts as options.
In reply to Thanks. When I open the… by odelphi231
Look at the files that come with the plugin. And the directory structure, here esp. the
translations
subdirectory and its content.The plugin's UI doesn't have and ts or qm files (they are in the above mentiond subdirectory, along with the scripts that generat them from the plugin code, the qml file in the parent directory), those do their work silently in the background.
The translation switches along with that of MuseScore itself (if German, Spanish, French or Italian, all others stay English)
In reply to Look at the files that come… by Jojo-Schmitz
Ok. I looked at the translation directory. It seems to have a bunch of other ts files for other language translations like french, italian and german. How do I use them on the file I wanna translate? What options do I click when I run the plugin? I am not trying to translate a Musescore score (mscx). I am trying to translate a plugin.
Unfortunately, this plugin doesn't come with a users guide except what is on the plugin page and all it tells you is how to convert to mscz or pdf.
In reply to Ok. I looked at the… by odelphi231
Why do you want an option in the plugin and what for?
You can't do anything with any of the ts or qm files for the plugin you what to translate, but this plugin should outline what steps it takes. Esp. the 2 .bat files (which need to get adjusted to point to your lupdate and lrelease and to your plugin code and to your desired language files)
In reply to Why do you want an option in… by Jojo-Schmitz
I am trying to automatically generate a "ts" file like "lupdate" does when I tell it what qml I want to translate. I don't know how to generate a ts file without lupdate. It is XML code and I don't know how to code in XML.
In reply to I am trying to automatically… by odelphi231
lupdate does that coding for you
In reply to Ok. I looked at the… by odelphi231
In the directory where yout plugin the qmp file, is, create a subdirectory 'translations'.
Copy the lrelease.bat and lupdate.bat into it.
Adjust the bat files to your needs path to the lrelease command, languages to create, etc.).
run lupdate.bat
open the now created ,ts files with QtLinguist and translate them (you could use a normal text editor too)
run lrlease.bat (QtLinguist can do that too)
In reply to In the directory where yout… by Jojo-Schmitz
Ok. I am starting to understand what you are saying. I looked at the bat file for "lupdate". All it does is run the "lupdate.exe" program. It is the lupdate.exe program that is giving me the error message and not producing a "ts" file. FYI: in the Translations directory, the bat files are actually called "lupdate.cmd" and "lrelease.cmd". Didn't realize they were bat files until you mentioned it.
In reply to Ok. I am starting to… by odelphi231
Oops. .bat and .cmd is basically the same thing though
If used correctly, lupdate does create .ts files
In reply to Oops. .bat and .cmd is… by Jojo-Schmitz
when I run the lupdate program in CMD, here is what happens (see attached pic). What am I not doing right for me to get the "some files have been ignored due to missing qml/javascript support". It tells me "found 0 source text(s). I am running the lupdate program like the help tells me to run it. It creates the ts file, but it is blank.
Like I said in my original post, this is a known error message from 5 years ago. Someone had to recompile the lupdate program (after doing some coding updates) in order to get it to work.
Any advice is appreciated.
In reply to when I run the lupdate… by odelphi231
The original colornotes_tpc plugin in the example doesn't have a user-visible UI element (menu, option, warning, etc.). I don't think there is anything translatable in this file (I could be wrong though).
In reply to The original colornotes_tpc… by Ziya Mete Demircan
I thought as long as the plugin had quoted text, it could be translated. This plugin has quoted text.
In reply to I thought as long as the… by odelphi231
> "I thought as long as the plugin had quoted text, it could be translated."
That's not how it works.
The text in the plugin has to be marked as translatable, for example by wrapping those texts in
qsTr
calls.In reply to > "I thought as long as the… by jeetee
OK. I thought the lupdate program does a search and replace to put qsTr on all the quoted text. Would be nice. However, this plugin does have 1 line with the qsTr call. So it should work. Also, if there is no translatable lines, is this the message I get: "Some files have been ignored due to missing qml/javascript support"? Then another message that says 0(zero) source files.
In reply to The original colornotes_tpc… by Ziya Mete Demircan
What I would like someone to do is pick a random plugin that has quoted text that could be translated and try to run lupdate to produce a ts file that opens in "Linguist". If it works, please tell me exactly how you ran the lupdate program and what version of lupdate you used.
Thanks
In reply to What I would like someone to… by odelphi231
That's not how it works. You need to tell lupdate which strings are to be translated, like by using qsTr("sometext").
What version of lupdate is used for this is pretty much irrelevant, and how exactly to use it in the batch convert plugin has been explained, or is docucumented in these cmd files.
The directory structure and naming convention is also important!
The command you used doesn't reflect any of those, it doesn't even look remotely similar to what these cmd files do.
Apart from that 'translating' in English (the "_en" in the name of the ts file) is probably not what you want.
In reply to That's not how it works. You… by Jojo-Schmitz
Jojo, sorry to disagree, but the ONLY thing missing from my command vs the cmd files are the options. I looked at the options and options are just that "optional" they are not required in order to create the "ts" file. But in order to satisfy you, I will run the command exactly like in the cmd files and see what happens. Running the batch convert plugin, is NOT the only way to create a translate file. The lupdate program existed before you created the batch convert plugin. The plugin I am trying to translate DOES have the qsTr ("sometext") commands. At the risk of sounding like a broken record, my original post mentioned that this error I am getting is a known error from 5 years ago and it hasn't been fixed in github.
In reply to Jojo, sorry to disagree, but… by odelphi231
No, it is using entirely different naming conventions and wouldn't work that way (with MuseScore).
The batch export plugin itself does not do translations at all, but it should serve as a working example how such translations are made and created.
I don't think there's anything to fix on GitHub? Known error from what or where?
Please share the plugin, and I'll have a closer look
In reply to Jojo, sorry to disagree, but… by odelphi231
Here's what my lupdate.cmd does on the plugin you ran it against further up:
Generates this:
And exactly that one string it extracts for translation doesn't work, and never did, not for this nor for any other plugin...
In reply to Here's what it does on that… by Jojo-Schmitz
Thank you for showing me how you ran it. I ran it exactly like you ran it, (of course my directories names are different from yours). Here is what happened.
And here are the results in the ts file. As you can see the ts file is empty. There should be that one line that your ts file has.
In reply to thank you for showing me how… by odelphi231
What is the content of the parent directory, D:\MuseScore3\plugins?
As said earlier: share the plugin rather than leaving us guessing.
Also as said earlier: an English translation may not help much?
What version of lupdate? Try
lupdate -version
.$ lupdate -version
lupdate version 5.15.2
Note the path that I'm using. I suspect your version is antediluvian
In reply to What is the content of the… by Jojo-Schmitz
Here is the version I am using. I attached the plugin. It is the same plugin that you used when you ran the command a little while ago. My D:\Musescore\plugin directory is where all my plugins are stored. However, I followed your directory convention and put the plugin I wanna translate into the "translations" directory. It is the only plugin in that directory. My whole raison d'etre for using this plugin is to use an easy plugin for translation. This one only has one line. (I thought it had more than one line, but someone corrected me and told me it only works on quoted text that has the qsTr command.)
D:\QTLinguist>lupdate -version
lupdate version 5.15.2
In reply to Here is the version I am… by odelphi231
OK, maybe lupdate stumbles accross one of the other files in that directory? Or it isn't installed completly?
Translations should better be kept per plugin, so you'd want that plugin in a directory of it own.
But then again: that plugin contains exactly one translatable string (and in English, so no need to translate it to English at all), the description, and that one doesn't work anyway (you can translate it, but MuseScore won't show it in the Plugin Manager), so what are you really trying to achieve, what plugin do you really want to translate? And into what language? That particular plugin is pretty much completly useless as far as translations are concerned.
In reply to OK, maybe lupdate stumbled… by Jojo-Schmitz
OK. If you want the full story here it is. I am going to "try" to tweak that plugin in order to learn how to program a plugin. It looked like an easy plugin to learn with. I noticed you were one of the programmers of that plugin. I ALSO thought, it would be a good plugin to learn how to translate a plugin into another language - didn't have a lot of quoted text. There, that is the full story why I chose that one. It doesn't matter what plugin I choose. It should still work.
I ran it with the plugin in its own directory and it still doesn't work.
In reply to OK. If you want the full… by odelphi231
See below, and get a good version of lupdate.
And pick a better plugin for practising, this one isn't worth it.
BTW: a quick Google search for "Some files have been ignored due to missing qml/javascript support" brings up this as the first hit: https://forum.qt.io/topic/32591/solved-lupdate-missing-qml-javascript-s…
And that seems spot-on. Your version of lupdate is not capable of dealting with qml/js files, period. Get the real version, from the Qt SDK
In reply to BTW: a quick Google search… by Jojo-Schmitz
OK. Maybe that is the issue. Where is the QT SDK? Is it already compiled or do I have to compile it first? If I remember correctly, I downloaded it from a free software website.
In reply to OK. Maybe that is the issue… by odelphi231
https://www.qt.io/download-qt-installer It is compiled already. Be selective in what you install from it, it is huge...
In reply to https://www.qt.io/download… by Jojo-Schmitz
Sorry, but I don't see it on that website. I used the search bar for linguist and lupdate and it didn't find anything.
In reply to Sorry, but I don't see it on… by odelphi231
Download and run that installer, in that make your selections what to install, Qt 5.15.2 > MSVC 2019 64-bit should be enough for a start
In reply to Download and run that… by Jojo-Schmitz
"Qt 5.15.2 > MSVC 2019 64-bit should be enough for a start"
I don't understand. I don't want a start. I want the official version of Linguist and lupdate. That is all I want. The installer is telling me that QT 5.15.2 will install 50GB on my harddrive. I don't wanna install 50GB on my harddrive. LInguist and lupdate are small programs.
In reply to "Qt 5.15.2 > MSVC 2019 64… by odelphi231
It won't get smaller.
In reply to It won't get smaller. by Jojo-Schmitz
OK. I unchecked some things that it had checked. Got it down to 1.7G. Is linguist and lupdate in that 1.7G?
In reply to OK. I unchecked some things… by odelphi231
Thank you Jojo. After some searching through a lot of directories that the QT installer made, I found the linguist and lupdate programs. It works now. Apparently the version I downloaded was compiled wrong or something.
A better plugin to practise translations on might be the "Hello QML" one that comes with MuseScore (and so far only a German translation)
In reply to A better plugin to practise… by Jojo-Schmitz
Thanks. I put the Hello QML plugin in my plugin directory, but it doesn't seem to work. Does it only print "Hello World" and then end? When I look at the code, it seems like it supposed to do more.
Also, I wanted to try to see if the German translation worked. So I switched my Musescore language to German. The Hello QML plugin did not switch to German. It was still in English.
In reply to Thanks. I put the Hello QML… by odelphi231
The message "Hello QML" is definitly translated to "Hallo QML" when running it in German. It isn't doing much more though and there seems to be an issue, seen when running it it the Plugin Editor/Creator
In reply to The messag "Hello QML" is… by Jojo-Schmitz
OK. Thanks. For future reference: All I have to do is put the plugin and the .qm file in the plugin directory and it should translate it right? They don't need to be put in a special directory and the .qm file doesn't need to have a certain file name in particular to work.
In reply to OK. Thanks. For future… by odelphi231
You need to keep the directory structure and the naming conventions, so the .qm need to be in translations/locale_[languagecode].qm (language code being de for German, de_DE fort German (Germany), etc.)
In reply to Thanks. I put the Hello QML… by odelphi231
Original helloqml is not correctly converted from MS2 I guess.
here is a fixed version for MS3
In reply to Original helloqml is not… by sammik
Thanks, added to https://github.com/musescore/MuseScore/pull/8985 and will do so shortly for https://github.com/musescore/MuseScore/pull/9000