QTranslator is a class from the Qt Toolkit which provides internationalization support for text output.
Questions tagged [qtranslator]
26 questions
4
votes
2 answers
How to differentiate between translation did not exist or the translation is the same as source?
I am using QCoreApplication::translate() to translate text.
I am trying to understand whether a string has a translation.
Qt documentation states:
If none of the translation files contain a translation for sourceText
in context, this function…

Kadir Erdem Demir
- 3,531
- 3
- 28
- 39
3
votes
2 answers
How can I include C:\Qt\5.9.1\msvc2015\translations .qm files (Qt framework qm files) in Visual Studio Qt project?
How can I include C:\Qt\5.9.1\msvc2015\translations .qm files (Qt framework qm files) in final release, Visual Studio Qt project?
I am loading the files using:
QTranslator* qtTranslator = new QTranslator();
bool ok = qtTranslator->load("qt_" +…

Mihai
- 389
- 1
- 4
- 16
3
votes
1 answer
Read translator file .ts/.qm on translations.qrc file
I'm trying to import translator file on my Qt project (Qt 5.6 on Linux system), but I can't upload translation file because the QTranslator::load method always returns false.
I have the following "testTrl" project structure:
On project root I have…

daniele86
- 147
- 3
- 14
2
votes
1 answer
How to log the original string of QObject::tr and still display to the GUI the translation?
In my project we want to translate the user-interface but keep the technical logs in English. I agree those two kind of messages should remain separated but sometimes we have some error messages that we want to display and log at the same…

ymoreau
- 3,402
- 1
- 22
- 60
2
votes
2 answers
Dynamically change translation of application with a combobox with pyqt
I'm creating a simple window with a combobox to let user choose the text language to be displayed throughout the app
I have created the necessary .qm files, and the text is being updated when I start the aplication. But how can I link this to the…

Elcook
- 165
- 2
- 10
2
votes
1 answer
Why my C++ Qt UI got translated but not my QStrings in my program?
I needed to translate my english UI in french, so I did all the necessary with .ts and .qm files, load it in the QTranslator class, and install it to the QApplication:
//in the InterfaceWidget constructor:
QTranslator myappTranslator;
bool loaded =…

toussa
- 1,058
- 12
- 21
2
votes
1 answer
How does QTranslator handle locale modifiers PyQT?
I'm experiencing a problem loading a translation file using QTranslator because it has a locale modifier in it. The code I'm using is,
from PyQt4 import QtCore, QtGui
from locale import getdefaultlocale
locale = getdefaultlocale()
app =…

Joshua Strot
- 2,343
- 4
- 26
- 33
1
vote
1 answer
Translation of Qt buttons not working with QTranslator
Usually I do translate my Python applications with GNU gettext. But I realized that standard elements (e.g. QDialogButtonBox.Yes) in a Qt GUI are not translated.
So I found examples with QTranslator. I'm not sure if this is the correct approach. I…

buhtz
- 10,774
- 18
- 76
- 149
1
vote
1 answer
How to use retranslateUi() recursively on all ui in QMainWindow?
In my Qt5 application I am trying to switch the language at run-time.
So far here my simple function:
QTranslator _translator;
void MainWindow::switchLanguage(QString lang)
{
if (!_translator.isEmpty()) qApp->removeTranslator(&_translator);
…

Mark
- 4,338
- 7
- 58
- 120
1
vote
1 answer
PyQt5 QTranslator translate not working with constants file
I am trying to learn pyqt and some mvc pattern stuff. I'd also like to have some translation for my app. Basic experiments worked great, so i tried to implement it within my app, but here i struggle right now.
here is where i initialize…

Canuma
- 59
- 4
1
vote
1 answer
QTranslator: why are some parts of app not translated?
There is a working app and I am adding a new language for GUI. Everything works fine but some part of the app are simply not translated. QLinguist detects all of them, and I have added a new translations, but still no result.
Here is the fragment of…

Bobur
- 545
- 1
- 6
- 21
1
vote
1 answer
Why language packs have to be loaded before main window is created in Qt?
I just learned how to set a language pack for my app in Qt, and I am currently have two questions. I wrote a minimal app to show where confused me.
I created a main window, which only contains a QLabel to show text and a QPushButton to change label…

Theodore Tang
- 831
- 2
- 21
- 42
1
vote
1 answer
How can I remove all QTranslator from the app?
I want to change the language using QCoreApplication::installTranslator with a few different .qm files for every language (different parts of the project result in different .qm files).
It is fine to use more than one .qm file…

ymoreau
- 3,402
- 1
- 22
- 60
0
votes
1 answer
QML translator error: only works if I add a translator.emptyString after qsTr
Using QML on Qt, I've setup up my QML Translator (called translator).
Running that code:
Text {
id: title
text: qsTr("title") + translator.emptyString
}
I get the translated message ("Whatever message")
Running this code:
Text {
id:…

Mendes
- 17,489
- 35
- 150
- 263
0
votes
1 answer
How to properly change Qt translation line (string) so it would be seen in Linguist
I'm working with existed code (.qml) and need to change line that translates by QTranslator with qm/ts translation files.
For example, the line in .qml file was:
item.text = qsTr("Old")
So I change it to:
item.text = qsTr("New")
But Linguist see…

Mykhailo V
- 1
- 3