View Single Post
rooster13's Avatar
Posts: 319 | Thanked: 221 times | Joined on Jan 2010 @ Finland
#42
Originally Posted by nicolai View Post
I don't remember :-)
I found this one in some example code or in the maemo developer
guide.

Nicolai
Hi Nicolai,

I tried with your approach but can't get it to work. As I'm usin Qt I can't use your code as is.

Here is how I am trying to get the comment.
First the translate QString, which returns the dgettext string passed in:
Code:
QStringDialog::translate(QStringdomain,QStringstr) 
{
QByteArraydomainBytes=domain.toLatin1(); constchar*domainPtr=domainBytes.data(); QByteArraystrBytes=str.toLatin1(); constchar*strPtr=strBytes.data(); setlocale(LC_ALL,""); returnQString::fromUtf8(dgettext(domainPtr,strPtr)); 
}
And then when reading the Desktop -files where I get the Comment and X-Text-Domain strings:
Code:
if(line.startsWith("Comment=")) { strList=line.split("="); if(strList.length()>=2) { comment=strList[strList.length()-1]; realComment=translate("maemo-af-desktop",comment); } } if(line.startsWith("X-Text-Domain=")) { strList=line.split("="); if(strList.length()>=2){ xTextDomain=strList[strList.length()-1]; realName=translate(xTextDomain,name); realComment=translate(xTextDomain,comment); } }
First I am trying to get the comment from the Comment -field of the Desktop -file. And then I am trying to get it from the X-Text-Domain. I am passing the values like this, because if dgettext finds nothing it returns the msgid passed to dgettext. A little bit of dodgy coding, but I'll fix it once I get this to work.

Do you have any ideas? Or is it that in GTK this stuff just works and not in Qt?

Last edited by rooster13; 2010-11-17 at 18:51.