Reply to topic

KGlobal::locale warning message [SOLVED]

Musikolo
Registered Member
Posts
27
Karma
0
OS
Hi mates;

I'm writting a program and everty time I started up I get the next message:

Starting: /home/musikolo/workspace-qt/myprogram/build/myprogram
KGlobal::locale::Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work


Thus, I've tried to go back to the basis, i.e., to do something as basic as this: http://techbase.kde.org/Development/Tut ... st_program But I still get the same warning message:
Starting: /home/musikolo/workspace-qt/myprogram/build/myprogram
KGlobal::locale::Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work
tutorial1(10658)/kdeui (KNotification) KNotificationManager::notificationClosed: 355
*** Exited normally ***


I'm addition to the warning message, I don't get my program to load the Spanish catalog, in spite of being created properly and installed here:

/usr/share/locale/es/LC_MESSAGES/myprogram.mo

What's wrong about the way I'm doing the localization process?

Best regards!

Last edited by Musikolo on Sat Feb 19, 2011 4:10 pm, edited 1 time in total.
pinotree
KDE Developer
Posts
222
Karma
7
OS

Re: KGlobal::locale warning message

Sat Feb 19, 2011 1:11 pm
Do you have any static i18n string, like
Code: Select all
static QString message = i18n("test");

or similar (like static class member) in your application?


Pino Toscano
Musikolo
Registered Member
Posts
27
Karma
0
OS

Re: KGlobal::locale warning message

Sat Feb 19, 2011 2:33 pm
@pinotree:
You were absolutely right. I have a line like next globally defined:

Code: Select all
static const QString NO_RESULT = i18n( "N/A" );


After checking a bit the code, I found out that it was used many times, but just in one method, so I moved it inside the method and the warning message disappeared.

So, thanks a lot for this. However, I still don't get my program to load the Spanish catalog I have made. I started it up like this:
Code: Select all
LANG=es_ES.UTF-8 ./myprogram


I have installed the package kde-l10n-es which seems to be required for some KDE-defined literals. By doing the same thing with, e.g., Kate editor, it works great though!

To make the catalog, I have used the next script to extract all literals http://pastebin.com/yc4dKRBW and used Lokalize to translate them into Spanish. After compiling all the literals, I have install it here: /usr/share/locale/es/LC_MESSAGES/myprogram.mo

Just for the sake of testing something different, I have added unsuccessfully the next line to my main.cpp file:
KGlobal::locale()->setActiveCatalog( "myprogram" );

What else could be wrong?
pinotree
KDE Developer
Posts
222
Karma
7
OS
Musikolo wrote:I have installed the package kde-l10n-es which seems to be required for some KDE-defined literals.

Yes, that contains (also) the base kdelibs translations, which are mandatory for any KDE application (meaning that without those any application won't get translations at all).

Musikolo wrote:To make the catalog, I have used the next script to extract all literals http://pastebin.com/yc4dKRBW and used Lokalize to translate them into Spanish. After compiling all the literals, I have install it here: /usr/share/locale/es/LC_MESSAGES/myprogram.mo

For "compiling" I guess you mean "using msgfmt", no?

Musikolo wrote:Just for the sake of testing something different, I have added unsuccessfully the next line to my main.cpp file:
KGlobal::locale()->setActiveCatalog( "myprogram" );

What else could be wrong?

You shouldn't need the line above. The catalog name of your application is named exactly after the first parameter (i.e. the application name) in the KAboutData created in the main() or, if not NULL/empty, the second parameter. So, make sure the .mo file you copy in the system path has the right name.


Pino Toscano
Musikolo
Registered Member
Posts
27
Karma
0
OS

Re: KGlobal::locale warning message

Sat Feb 19, 2011 4:08 pm
@pinotree:

Thanks mate, you mentioned the clue I needed:

pinotree wrote:The catalog name of your application is named exactly after the first parameter (i.e. the application name) in the KAboutData created in the main() or, if not NULL/empty, the second parameter.

I was using the capital letters in the first two parameters my of KAboutData object and this was my mistake.

Thanks a million for your immense help!

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], crispiatico, Exabot [Bot], Google [Bot], louis94, Nyugame, Sogou [Bot], sudo0272, Yahoo [Bot]