joachim99@55: README for KDiff3-Internationalisation (i18n) joachim99@55: ============================================= joachim99@55: Author: Joachim Eibl 2004 joachim99@55: joachim99@55: This text is for you, if you might want to help translating KDiff3 or just want joachim99@55: to learn how this i18n-thing works. joachim99@55: joachim99@66: grep "Language-Team" *.po joachim99@55: joachim99@66: az Azerbaijani joachim99@66: ca LANGUAGE joachim99@66: da Danish joachim99@66: de Deutsch joachim99@66: en_GB British English joachim99@66: es espaniol joachim99@66: et Estonian joachim99@66: fr French joachim99@66: hu Hungarian joachim99@66: it Italian joachim99@66: nl Nederlands joachim99@66: pl Polish joachim99@66: pt_BR Brazilian Portuguese joachim99@66: pt Portuguese joachim99@66: ro Romanian joachim99@66: ru Russian joachim99@66: sr Serbian joachim99@66: sv Svenska joachim99@66: ta joachim99@66: tr Türkçe joachim99@66: zh_CN zh_CN joachim99@55: joachim99@55: joachim99@55: Thanks to all translators! joachim99@55: joachim99@55: joachim99@55: The program was written with English as main language. But to allow automatic joachim99@55: translation of messages, every translatable text in the program was written as joachim99@55: i18n("translatable"). joachim99@55: joachim99@55: i18n() is a translator-function. If a translation table exists, at runtime the joachim99@55: function looks for the given string in that table and returns the translation. joachim99@55: joachim99@55: The translation-table is created in 3 steps: joachim99@55: 1. First a template-translation table kdiff3.pot should be created: Usually via joachim99@55: xgettext --keyword=i18n --keyword=I18N_NOOP -C -o ../po/kdiff3.pot *.cpp *.h joachim99@55: joachim99@55: It contains all translatable strings of the program, but no translations. joachim99@69: (xgettext is usually part of package gettext-devel) joachim99@80: Better to get version from kde svn: joachim99@80: wget http://websvn.kde.org/*checkout*/trunk/l10n-kde4/templates/messages/extragear-utils/kdiff3.pot joachim99@80: wget http://websvn.kde.org/*checkout*/trunk/l10n-kde4/templates/messages/extragear-utils/kdiff3plugin.pot joachim99@55: joachim99@55: 2. Translators create a translation for a specific language. Because we don't want joachim99@55: to modify the template now, we'll create a copy for each language. joachim99@55: e.g.: cp kdiff3.pot de.po joachim99@55: Using KBabel we can comfortably edit the translated strings. joachim99@55: e.g.: kbabel de.po joachim99@55: joachim99@55: 3. The last step is to create a fast lookup-table (*.gmo) from the po-file via joachim99@55: msgfmt, but this happens automatically during the build process. joachim99@55: (If a new po-file was added: make -f Makefile.cvs; configure; make) joachim99@55: joachim99@59: Before starting to translate make sure nobody else is already doing it. It would joachim99@59: be a pity, if your precious time is wasted. Look at http://i18n.kde.org/, send a joachim99@59: message to the translation team coordinator for your language, and tell them that joachim99@59: you want to translate KDiff3. He'll inform you if you should proceed. Also read joachim99@59: the other docs on that site. joachim99@59: joachim99@55: ============ joachim99@55: joachim99@55: The following is for my own memory and for those who really want to learn dirty tricks and details: joachim99@80: The script "update_po_dirs" does all in here automatically. Read on if you want details. joachim99@55: joachim99@69: The KDE-i18n team stores their results in SVN. But I would like to have an independent joachim99@55: copy of all translations in the po-directory of the source package. Actually it's just joachim99@55: copying and renaming, but simplified with these commands: joachim99@55: joachim99@69: First fetch all available translations from the SVN-repository (access via websvn and wget) joachim99@69: wget http://websvn.kde.org/*checkout*/trunk/l10n/subdirs joachim99@80: for i in `cat subdirs`; do wget http://websvn.kde.org/*checkout*/trunk/l10n-kde4/$i/messages/extragear-utils/kdiff3.po -O $i.po; done joachim99@55: joachim99@55: This was the explanation for translations within KDE. joachim99@55: But KDiff3 can also be compiled and run without KDE: joachim99@55: joachim99@55: Since Qt was used for KDiff3, the first part is quite the same: Only the fast lookup-table joachim99@80: (*.qm-files) must be created with $QTDIR/bin/msg2qm (instead of msgfmt). ($QTDIR/tools/msg2qm in the "qt3-devel-tools"-package)) joachim99@55: joachim99@55: Still one detail isn't right: Some strings are not translated, because under KDE their joachim99@55: translation is within KDE-libs or within Qt. But the translations are available: joachim99@55: joachim99@55: For Qt-strings in $QTDIR/translations (already as .qm-files) joachim99@55: joachim99@75: For KDE-libs in the SVN-repository, where we can reuse the previous trick to get joachim99@55: all kdelibs*.po-files: joachim99@69: joachim99@80: for i in `cat subdirs`; do wget http://websvn.kde.org/*checkout*/trunk/l10n-kde4/$i/messages/kdelibs/kdelibs4.po -O kdelibs_$i.po; done joachim99@55: joachim99@55: Finally the program must only read the correct translation tables: joachim99@55: joachim99@55: QTranslator kdiff3Translator( 0 ); joachim99@66: kdiff3Translator.load( QString("kdiff3_")+QTextCodec::locale(), translationDir ); joachim99@55: app.installTranslator( &kdiff3Translator ); joachim99@55: joachim99@55: QTranslator qtTranslator( 0 ); joachim99@55: qtTranslator.load( QString("qt_")+QTextCodec::locale(), translationDir ); joachim99@55: app.installTranslator( &qtTranslator ); joachim99@55: joachim99@55: QTranslator kdelibsTranslator( 0 ); joachim99@55: kdelibsTranslator.load( QString("kdelibs_")+QTextCodec::locale(), translationDir ); joachim99@55: app.installTranslator( &kdelibsTranslator ); joachim99@55: joachim99@55: This should do the job, if the translation-tables can be found. joachim99@55: The difficult part is: Where to search for the files, because this depends on joachim99@55: where the program was installed. (I didn't solve this puzzle yet.) joachim99@55: joachim99@55: Because it's too much effort to copy all kdelibs*.po-files along: Here is a little info joachim99@55: about how to extract only the needed strings and to create the qm-files. joachim99@55: joachim99@80: Steps 1-3 are obsolete for translations that are up to date because kreplacements.pot is now in kde-svn-repository. joachim99@55: 1. Only src/kreplacements/kreplacements.cpp contains strings, that were not covered by joachim99@55: the normal translations. Hence a special pot-file is needed. joachim99@55: xgettext --keyword=i18n --keyword=I18N_NOOP -C ../src/kreplacements/kreplacements.cpp -o kreplacements.pot joachim99@69: (xgettext is usually part of package gettext-devel) joachim99@55: joachim99@55: 2. Take only needed strings and translations from kdelibs*.po: joachim99@55: msgmerge --no-fuzzy-matching kdelibs_de.po kreplacements.pot >kreplacements_de.po joachim99@80: ("msgmerge" and "msgcat" are part of the "gettext-tools"-package.) joachim99@55: joachim99@55: 3. Concatenate the normal de.po and kreplacements_de.po: joachim99@55: msgcat --use-first de.po kreplacements_de.po >kdiff3_de.po joachim99@80: The resulting file is huge, but most stuff is commented out. joachim99@55: joachim99@80: 4. Finally create the fast lookup table (msg2qm is from "qt3-devel-tools"-package): joachim99@55: $QTDIR/bin/msg2qm kdiff3_de.po kdiff3_de.qm joachim99@55: joachim99@55: 5. The intermediate files can then be deleted. joachim99@55: joachim99@80: Creating the directory structure needed for KDE4 and cmake. joachim99@80: for i in *.po; do echo $i; export j=`echo $i | sed s/.po//`; echo $j; md $j; cp $j.po $j/kdiff3.po; sed s/xx/$j/ CMakeLists_xx.txt >$j/CMakeLists.txt ; done joachim99@80: (For each po-file create the subdir, copy outer po-file to subdir/kdiff3.po and create a CMakeLists.txt file.) joachim99@80: ls */kdiff3.po | sed 's/\(.*\)\/.*/add_subdirectory(\1)/' >CMakeLists.txt joachim99@80: