summaryrefslogtreecommitdiffstats
path: root/po/README
blob: 5093dff69bcc73514cc8acba9b1d0dbfcea21dad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
README for KDiff3-Internationalisation (i18n)
=============================================
Author: Joachim Eibl 2004

This text is for you, if you might want to help translating KDiff3 or just want 
to learn how this i18n-thing works.

grep "Language-Team" *.po

az     Azerbaijani <[email protected]>     
ca     LANGUAGE <[email protected]>     
da     Danish <[email protected]>     
de     Deutsch <[email protected]>     
en_GB  British English <[email protected]>     
es     espaniol <[email protected]>     
et     Estonian <[email protected]>     
fr     French <[email protected]>     
hu     Hungarian <[email protected]>     
it     Italian <[email protected]>     
nl     Nederlands <[email protected]>     
pl     Polish     
pt_BR  Brazilian Portuguese <[email protected]>     
pt     Portuguese <[email protected]>     
ro     Romanian <[email protected]>     
ru     Russian <[email protected]>     
sr     Serbian
sv     Svenska <[email protected]>     
ta      <[email protected]>     
tr     Türkçe <[email protected]>     
zh_CN  zh_CN <[email protected]>     


Thanks to all translators!


The program was written with English as main language. But to allow automatic
translation of messages, every translatable text in the program was written as 
i18n("translatable").

i18n() is a translator-function. If a translation table exists, at runtime the 
function looks for the given string in that table and returns the translation.

The translation-table is created in 3 steps:
1. First a template-translation table kdiff3.pot should be created: Usually via
   xgettext --keyword=i18n --keyword=I18N_NOOP -C -o ../po/kdiff3.pot *.cpp *.h 
   
   It contains all translatable strings of the program, but no translations.
   (xgettext is usually part of package gettext-devel)
   
2. Translators create a translation for a specific language. Because we don't want 
   to modify the template now, we'll create a copy for each language.
   e.g.: cp kdiff3.pot de.po
   Using KBabel we can comfortably edit the translated strings.
   e.g.: kbabel de.po
   
3. The last step is to create a fast lookup-table (*.gmo) from the po-file via 
   msgfmt, but this happens automatically during the build process.
   (If a new po-file was added: make -f Makefile.cvs; configure; make)

Before starting to translate make sure nobody else is already doing it. It would 
be a pity, if your precious time is wasted. Look at http://i18n.kde.org/, send a 
message to the translation team coordinator for your language, and tell them that  
you want to translate KDiff3. He'll inform you if you should proceed. Also read
the other docs on that site.

============
   
The following is for my own memory and for those who really want to learn dirty tricks and details:
   
The KDE-i18n team stores their results in SVN. But I would like to have an independent 
copy of all translations in the po-directory of the source package. Actually it's just
copying and renaming, but simplified with these commands:


First fetch all available translations from the SVN-repository (access via websvn and wget)
   wget http://websvn.kde.org/*checkout*/trunk/l10n/subdirs
   for i in `cat subdirs`; do wget http://websvn.kde.org/*checkout*/trunk/l10n/$i/messages/extragear-utils/kdiff3.po -O $i.po; done
   
   
This was the explanation for translations within KDE. 
But KDiff3 can also be compiled and run without KDE:

Since Qt was used for KDiff3, the first part is quite the same: Only the fast lookup-table 
(*.qm-files) must be created with $QTDIR/bin/msg2qm (instead of msgfmt). ($QTDIR/tools/msg2qm)

Still one detail isn't right: Some strings are not translated, because under KDE their 
translation is within KDE-libs or within Qt. But the translations are available:

For Qt-strings in $QTDIR/translations (already as .qm-files)

For KDE-libs in the SVN-repository, where we can reuse the previous trick to get 
all tdelibs*.po-files:

   for i in `cat subdirs`; do wget http://websvn.kde.org/*checkout*/trunk/l10n/$i/messages/tdelibs/tdelibs.po -O tdelibs_$i.po; done
   
Finally the program must only read the correct translation tables:

   QTranslator kdiff3Translator( 0 );
   kdiff3Translator.load( QString("kdiff3_")+QTextCodec::locale(), translationDir );
   app.installTranslator( &kdiff3Translator );
   
   QTranslator qtTranslator( 0 );
   qtTranslator.load( QString("qt_")+QTextCodec::locale(), translationDir );
   app.installTranslator( &qtTranslator );
   
   QTranslator tdelibsTranslator( 0 );
   tdelibsTranslator.load( QString("tdelibs_")+QTextCodec::locale(), translationDir );
   app.installTranslator( &tdelibsTranslator );

This should do the job, if the translation-tables can be found. 
The difficult part is: Where to search for the files, because this depends on 
where the program was installed. (I didn't solve this puzzle yet.)

Because it's too much effort to copy all tdelibs*.po-files along: Here is a little info
about how to extract only the needed strings and to create the qm-files.

1. Only src/kreplacements/kreplacements.cpp contains strings, that were not covered by 
   the normal translations. Hence a special pot-file is needed.
   xgettext --keyword=i18n --keyword=I18N_NOOP -C ../src/kreplacements/kreplacements.cpp -o kreplacements.pot
   (xgettext is usually part of package gettext-devel)
   
2. Take only needed strings and translations from tdelibs*.po:
   msgmerge --no-fuzzy-matching tdelibs_de.po kreplacements.pot >kreplacements_de.po

3. Concatenate the normal de.po and kreplacements_de.po:
   msgcat --use-first de.po kreplacements_de.po >kdiff3_de.po

4. Finally create the fast lookup table:
   $QTDIR/bin/msg2qm kdiff3_de.po kdiff3_de.qm

5. The intermediate files can then be deleted.

The script createqm does steps 2-5 for languages where a kdiff3.po-translation exists.