PDA

View Full Version : translate QIODevice::errorString()



zaphod.b
22nd April 2014, 17:20
Hi all,

Should/does Qt provide translations for e.g. QIODevice::errorString()?

For example, when trying to QFile::open() a readonly file for writing, errorString() gives "Access is denied.". This string I'd like to translate, but rather not on my own. :rolleyes:

I have loaded qt[base]_*.qm to no avail. The *.ts I have not at my hands currently, so I can't look into these.

ChrisW67
23rd April 2014, 07:15
There is no direct translation support for QIODevice, it simply repeats whatever a subclass sets using QIODevice::setErrorString(). QFile does set strings marked for translation and, for example, there is a French translation in the qt_fr.ts that I would assume is automatically picked up on machines with a French locale.

zaphod.b
24th April 2014, 15:59
Thx Chris.

In the meantime I installed qt-everywhere-opensource-src-5.2.1 and looked into qtbase_*.ts. The exact string "Access is denied." is not in there. In fact, it can't be found in any file therein!
(Apart from sqlite.* and tst_xmlpatterns.cpp which are irrelevant for my case.)

So the only reasonable assumption left is: It's delivered by the underlying runtime (MSVC 2010 in my case) which probably passes it through from the OS. Is that so? Although in theory it could be some hardcoded Unicode which my search didn't cover.

Changing my Windows Desktop's display language from english to something else doesn't affect the error string either.

Where does that string come from?


QFile does set strings marked for translation and, for example, there is a French translation in the qt_fr.ts that I would assume is automatically picked up on machines with a French locale.
If you found the string inside qt_fr.ts then surely you didn't check 5.2? Translations have been modularized and QFile context is in qtbase_*.ts now.

me21
29th January 2016, 10:23
I've encountered a similar problem. Only the string is different: "No file name specified". It is hardcoded in qtbase/src/corelib/io/qfsfileengine.cpp and it's not marked for translation. Qt 5.4.2.