Internationalization

Atnaujinta prieš 4 years

This documentation applies to plugins for 1.x only!


Documentation for 2.x+ is built into the Plugin Creator of Musescore.

( ⇒ In Musescore press Ctrl+Shift+P, then F1 to bring it up. )


Click here for Documentation for 3.x



To translate a plugin, you need to use qsTr() for all your "quoted strings" in the .js files. qsTr() has 2 arguments, the 1st is the to be translated string, the 2nd is a comment to the translator (and later visible in Qt Linguist) and optional.
It can work with placeholders, e.g. qsTr("Pages: %1") .arg(NumberOfPages)
If the string is outside a function, use QT_TR_NOOP(). For example, for the [[nodetitle:Plugin File Structure|menu item]] , use QT_TR_NOOP("Plugins.MyMenuItem")
(although, as per this forum thread the term 'Plugins' should not get translated, not yet at least)

Not extra steps needed for .ui files.

Next the plugin needs a directory on its own, do not conflict with other plugins' translations

Then create a directory translations into the plugins' directory. You need to put locale_XX.qm files in it. How to obtain a .qm file for your plugin?
Run
replace XX by the targetted language (eg.: "de" for German) and include .js and .ui files
lupdate translations/locale_XX.ts
This extracts all the to be translated strings from ther .js and .ui files into that .ts file.
Repeat for other languages, if need be.

Use Qt Linguist to put the translation into locale_XX.ts. Once done use FileRelease in Qt Linguist or run the following:
lrelease translations/locale_XX.ts
That will create/update a locale_XX.qm file.
Now, run MuseScore in your language and your plugin should be translated!

More information on QtScript website.

If you want to look at working examples, check the batch export plugin and/or the MuseScore 1.2+ version of the musescore.com plugin ("Save online").