We are Borg
We are Borg

Reputation: 5311

QT: translation using button

Hello friends, I am creating some labels and information box in qt designer. Also i have created a push button for translation purposes. QT has &tr for whichever text can be translated to other language. Is there any way to connect this to the push button, where a drop down menu will tell the language choices. Or is there a way to save the translations somewhere and then bring them at the click of the push button. Kindly let me know. Thank you for your time.

Upvotes: 0

Views: 381

Answers (1)

Pavel Strakhov
Pavel Strakhov

Reputation: 40502

Qt translations are saved in .ts files (one file for each language). If you have several translation files, you can put them into resources or in the installation directory.

you can get language list just as you can get usual files list - using QDir::entryInfoList. Or you can hardcode translations list in the source code.

You can load translation file using QCoreApplication::installTranslator and remove it using QCoreApplication::removeTranslator.

See also:

Upvotes: 1

Related Questions