From kde-devel Wed Feb 27 15:58:23 2002 From: Stephan Kulow Date: Wed, 27 Feb 2002 15:58:23 +0000 To: kde-devel Subject: Re: Translation (i18n) question X-MARC-Message: https://marc.info/?l=kde-devel&m=101482569114057 On Wednesday 27 February 2002 16:43, mh wrote: > Hans Petter Bieker, Mittwoch, 27. Februar 2002 13:24: > > On Sat, 23 Feb 2002, mh wrote: > > > is it possible to load a catalogue (*.mo), which is not located in = KDEs > > > standard location? > > > I.e. if I know the absolute path /some_path/bla.mo, is it then poss= ible > > > to load this file through KLocale? > > > The only function I could find is insertCatalogue(), but it seems, = that > > > this function assumes, that the catalogue is located in KDEs "local= e" - > > > dir. Or shorter: Is there something like QTranslator::load() for > > > KLocale? > > > > No. Why do you need it? Perhaps you can use KCatalogue directly. > > Because I need to access the translation supplied by another library > (libsane). Stephan Kulow already pointed out, that this can be done wit= h > KGlobal::dirs()->addResourceDir() and KLocal::insertCatalouge(). > However, as I wrote in a followup, the translated strings aren't displa= yed > correctly (missing "Umlaute" or vowel mutations). I thought (without > knowing much about KDEs i18n framework), that this is due to the fact, = that > the .po files are not utf8 encoded. > I did some additional tests: > 1.If I use bindtextdomain() and textdomain() and then > QString translated_string =3D gettext(untranslated_char_string) > it works without problems. > > 2. If I use my own .mo file loader in conjunction with QTranslator, it > seems to work too: > QString qs =3D translated_char_string_from_mo_file; > QString qs2 =3D QString::fromUtf8(qs); > qs2 =3D QString(qs2.utf8()); > QString translated_string_for_translator; > if(qs =3D=3D qs2) > translated_string_for_translator =3D QString::fromUtf8(qs); > else > translated_string_for_translator =3D qs.local8Bit(); > QTranslator trans.insert(QTranslatorMessage(scope,original_char_string, > translated_string_for_translator)= ); > > So why doesn't this work with KLocal::insertCatalouge() ? As far as I c= an > tell, KDE simply uses libintl ported to C++ (kdecore/libintl.cpp). > And more important, how should I proceed now? > Anyone, please... > Encode your PO files in UTF-8 Greetings, Stephan --=20 life is too short to make mistakes >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<