Plugin translation

• Aug 30, 2021 - 19:52

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

In reply to by odelphi231

Look at the files that come with the plugin. And the directory structure, here esp. the translationssubdirectory 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 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 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 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 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 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.

lupdatepic.png

In reply to 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 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 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 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 by odelphi231

Here's what my lupdate.cmd does on the plugin you ran it against further up:

C:\Users\Jojo\Downloads\ColorNotes_tpc_1\translations $ C:/Qt/5.15.2/mingw81_64/bin/lupdate .. -no-obsolete -locations absolute -ts locale_de.ts locale_es.ts locale_fr.ts locale_it.ts
Scanning directory '..'...
Updating 'locale_de.ts'...
    Found 1 source text(s) (1 new and 0 already existing)
Updating 'locale_es.ts'...
    Found 1 source text(s) (1 new and 0 already existing)
Updating 'locale_fr.ts'...
    Found 1 source text(s) (1 new and 0 already existing)
Updating 'locale_it.ts'...
    Found 1 source text(s) (1 new and 0 already existing)

C:\Users\Jojo\Downloads\ColorNotes_tpc_1\translations $ pause
Drücken Sie eine beliebige Taste . . .

Generates this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
    <name>ColorNotes_tpc</name>
    <message>
        <location filename="../ColorNotes_tpc.qml" line="22"/>
        <source>This plugin colors notes in the selection depending on their pitch as per the Boomwhackers convention</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>

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 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.
lupdatepic2.png

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.

locale_enpic.png

In reply to 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 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

Attachment Size
ColorNotes_tpc.qml 5.67 KB

In reply to 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 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 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.

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 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 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

Läuft…
Plug-In Details:
  Menü Pfad: Plugins.helloQml
  Version: 3.0
  Beschreibung: Dieses Demo-Plugin zeigt einige einfache Funktionen.
  Benötigt Partitur
Debug: Hallo Welt
Debug: Ms::PluginAPI::Score(0x24ef75a0)
Debug: Score
19:-1: TypeError: Property 'firstMeasure' of object Ms::PluginAPI::Score(0x24ef7660) is not a function
Warning: file:///C:/Program Files/MuseScore 3/plugins/helloqml/helloqml.qml:19: TypeError: Property 'firstMeasure' of object Ms::PluginAPI::Score(0x24ef7660) is not a function

In reply to 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.

Do you still have an unanswered question? Please log in first to post your question.