]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - locale/README
slightly improved docs
[SourceForge/phpwiki.git] / locale / README
1
2 This document describes how to add a new language translation to PhpWiki.
3
4 If you just want to use one of the existing language translations, see
5 part four 'config/config.ini' for the DEFAULT_LANGUAGE or your special
6 starter script (index.php) to change the current or default language
7 of your Wiki. Modify or add a line that sets $LANG to use the two-letter
8 code of one of the supported languages, like this:
9
10     // Select your language/locale - default language "C": English
11     // other languages available: Dutch "nl", Spanish "es", German "de",
12     // Swedish "sv", and Italian, "it".
13     // $LANG="C";
14     $LANG="it";
15
16
17 Phpwiki uses GNU gettext tools to provide and maintain multi-lingual
18 messages for different languages. Even if you are already familiar
19 with xgettext you will want to read this document to be aware of
20 translation issues and tips specific to PhpWiki; perhaps skimming
21 through the Makefile section.
22
23 PhpWiki does not require gettext support to be compiled in to PHP. It
24 automatically provides a pure PHP replacement in case it's not
25 available.
26
27
28 Formalities
29 ===========
30 The modern English language has no clear rules for differentiating
31 between the formal and informal use of the spoken word. This both
32 simplifies and complicates matters for translators, as many languages
33 do still make such a distinction. For the most part, PhpWiki is written
34 using the casual forms of messages and explanatory text--after all the
35 WikiWikiWeb is an open and friendly place. :-)
36
37 However, there is no reason why translations of Wiki commands like
38 "Edit" or "FindPages" should not be written formally. For the sake of
39 recognition or clarity when the word function is the same as another
40 common computer term or menu-item, if you feel it would be more
41 effective to employ a formal variation then please do so. When the
42 formal word is significantly longer than the informal word, make a
43 judgement call or substitute an abbreviation, provided that it will
44 be easily recognised.
45
46 Remember that a good and thorough translation is a subjective and
47 collective process. Once people have had a chance to test-drive your
48 newly-translated PhpWiki there will always be suggestions for
49 reshaping and improving it.
50
51 Diversity and Change are part of WikiEssence. By all means don't
52 belabour the translation process, and have some fun!
53
54
55 General Steps
56 =============
57 The general steps to creating a new language module for PhpWiki:
58
59 1. Copy and rename the master template to create a new file for your
60    language ('phpwiki.pot' => 'xx.po').
61
62 2. Translate all the strings in the new language file ('.po file').
63
64 3. Run 'make' to automatically create or update any additional files
65    ('.po' => '.mo' => 'phpwiki.php' files).
66
67 4. Create translations of the content for the default pages ('pgsrc'
68    files).
69
70
71 Example
72 =======
73 Let's assume for example that you would like to add an Islandic
74 translation to PhpWiki.
75
76
77 Text Strings
78 ------------
79 Duplicate the file phpwiki.pot in the 'locale/po/' folder and name it
80 'is.po' ('is' is the code for Islandic). Next, translate all the
81 strings inside 'is.po' from English to Islandic. Unix Hint: Emacs has
82 a handy "po translation mode" for you. See README.coding in the doc folder.
83
84
85 Character Encoding
86 ------------------
87
88 Currently most of the language files are saved using the ISO-8859-1
89 character encoding to preserve accented characters. Make sure the text
90 editor you use is capable of performing the appropriate Latin-1
91 translation. Strictly speaking, ISO-8859-1 is *different* than Windows
92 code page 1252 or MacRoman. Upon quick inspection one will notice that
93 many of the letters do occupy the same positions in each of their'
94 respective encoding tables, so it is easy to understand how people can
95 make this false assumption.
96
97 Limitation:
98 PhpWiki is not able to translate between different character sets on the 
99 fly (iconv). Certain languages, like Japanese or Chinese use special character 
100 sets (euc-jp, utf-8), which must be defined in part four in config/config.ini.
101 Therefore other languages in different character sets will not be correctly 
102 displayed.
103
104 Word Reordering
105 ---------------
106 Different languages have different word ordering requirements. When a
107 key word such as a person's name needs to be added to the end of a
108 sentence in english, there is no guarantee that the same word will
109 appear at the end of a sentence once translated to another language.
110
111 PhpWiki has been designed with this in mind. (Standard printf
112 notations like %s and %1$s, %2$s will work with PhpWiki, even though
113 reordering of variable-substitutions is not actually part of PHP).
114 (The printf(3) manual page on your system may be of some help.)
115
116
117 Take the following English phrase as an example. This message would be
118 displayed in the browser when someone wants to compare two revisions
119 of a Wiki page. The corresponding entry for the German translation for
120 this phrase (from the file 'de.po') reads:
121  
122     #: ../lib/diff.php:251
123     #, c-format
124     msgid "Differences between %s and %s of %s."
125     msgstr "Der Unterschiedsergebnis von %3$s, zwischen %1$s und %2$s"
126
127 In the English version, PhpWiki will substitute the phrases "version
128 1", "version 2" and the name of the page being compared. The
129 placeholder '%s' indicates where text will later be substituted, while
130 '%d' is used to indicate a number will be inserted.
131
132 Sentence structure of German is different than English, and this case
133 dictates that the "page name" must come first, then followed by
134 "Verson 1." and finally "Version 2."
135
136 To summarize, when the word ordering must differ, insert "1$", "2$"
137 etc. into the middle of '%s' and repeat for each instance of '%s' in
138 the phrase.  If you use this "$" notation, you must use it for each
139 of the the format specifications within the string.
140
141 Here are a couple more examples. They are fictional but they serve to
142 illustrate how to handle special cases, should they arise:
143
144
145 #msgid "Page version '%d' named '%s' is not available."
146 #msgstr "Xyqlmn vvvm » %2$s « mnqee » %1$d « Gvbbbnbhkkk eeek."
147
148 The %s and %d are reversed, so '2$' and '1$' have been used to
149 indicate the new ordering. The punctuation marks for this language
150 dictate extra spacing, so this has also been accounted for in the
151 translation (i.e. the quote marks are only for emphasis, they are not
152 considered part of the %s placeholder).
153
154
155 #msgid "Page named '%s' version '%d' written by author '%s' is not available."
156 #msgstr "Qppn wwmoooppp '%3$s' vvvm '%1$s' mnqee '%2$d' Gvbbbnbhkkk eeek."
157
158 Name and author are reversed. Even though the position of the number
159 ('%d') isn't changed, still it must be changed to '%2$d' --- if you
160 use a '$' on one of the format specifiers you must use it on all of
161 them.  The punctuation for this particular language is the same as
162 english so it is unchanged.
163
164
165 While translating the text strings if you are uncertain about the
166 syntax, look at the '.po' files of the other languages as an
167 example. If you are stuck or simply can't make any sense of all this,
168 just ask one of the PhpWiki programmers on the mailing list to help
169 out.
170
171 The 'phpwiki.php' files do not need to be created or edited because
172 the Makefile will create and update these files automatically. See the
173 'Makefile' section below.
174
175
176 Default Pages
177 -------------
178 Most of the work will be in the translation of the default pgsrc
179 files. As a starting point you can copy the English 'pgsrc' directory:
180
181     mkdir locale/is
182     cp -rv pgsrc locale/is
183
184 For these 'pgsrc' files it will be sufficient to change the page names
185 to Islandic, and maybe translate the HomePage and give it an Islandic
186 name. Again, for anything you don't know, look at the 'nl' or 'de'
187 versions.
188
189 The best approach to translating the default page content is to do all
190 of your page editing in the web browser itself, then perform a page
191 dump to save the pages as MIME text files.  Some of the pages are
192 locked so you will have to log into PhpWiki as the administrator
193 before you can edit them.
194
195 <FIXME>
196    Add instructions for editing MIME headers of files before moving
197    files into '/locale/is/pgsrc'
198
199  - keep modification date, page name and lock, remove author.
200    Use action=PageDump - "Preview as developer format" for this.
201    Example:
202
203    Date: Sun, 27 Jan 2002 17:28:55 -0500
204    Mime-Version: 1.0 (Produced by PhpWiki 1.3.2-jeffs-hacks)
205    X-Rcs-Id: $Id: README,v 1.12 2004-06-19 12:13:57 rurban Exp $
206    Content-Type: application/x-phpwiki;
207      pagename=Neueste%C4nderungen;
208      flags=PAGE_LOCKED;
209      charset=iso-8859-1
210    Content-Transfer-Encoding: binary
211
212  - Make sure to rename files with accents in the page name converted
213    to uppercase hex codes as shown in the pagename= line of the
214    Content-Type header.
215
216    (e.g. "GästeBuch" => "G%E4steBuch")
217
218  - Translate body text and rename plugin pages to match changes
219    specified in the '.po' file. Leave plugin code as english.
220    Example:
221
222    <?plugin RecentChanges days||=30 show_all||=0 show_minor||=0 ?>
223
224 </FIXME>
225
226
227 Makefile
228 -------- 
229 The Makefile calls 'xgettext' to automatically perform a number of
230 important translation tasks:
231
232  * Scans through all the source code and retrieves the english
233    strings used as text arguments, then collects and indexes them into
234    the file 'phpwiki.pot'.
235
236  * Merges any new differences of the collected English text strings
237    with similar text strings found during any previous runs of 'make',
238    stored inside each of the translated '.po' files.
239
240  * Makes note of which English text strings have been added, reworded
241    or removed. The translated strings in the '.po' files are then marked
242    as "Fuzzy" translations for all cases where the English text has been
243    changed. This makes it easy for translators to spot which items need
244    to be updated. (Emacs' po mode also uses this information).
245
246  * The necessary '.mo' files and 'phpwiki.php' text files are
247    synchronized and sorted according to the translated contents of the
248    '.po' files, for each of the locale subdirectories.
249
250 When a new language module is added to PhpWiki, the 'Makefile' in the
251 'locale' folder also needs to be updated. The process:
252
253  0. Change into the locale directory (if you're not already there.)
254
255  1. If there isn't one already, Create a new .po (in the po/ subdirectory)
256     for your translations:
257
258       cp po/phpwiki.pot po/xx.po
259
260     where 'xx' should be the two letter character code for the language
261     you are translating to.
262
263  2. If you've created a new .po file (or if there are new .php source files
264     containing translatable strings,) update the Makefile:
265  
266       make dep
267
268  3. To make sure the list of translatable strings in the .po is in sync
269     with the actual php source code:
270  
271       make po
272
273  4. Edit the translations in the .po file.  If you have emacs available,
274     emacs' po-mode is very helpful when doing this.
275
276  5. Translators may include comments in the po file. If using a text
277     editor other than emacs (with po-mode), add any comments BEFORE an
278     entry, and prefix each line with # like this:
279
280 # This entry is important for French punctuation rules which stipulate
281 # a space before each colon.
282 #: ../lib/display.php:54 ../lib/plugin/PageGroup.php:91
283 #: ../lib/plugin/PageGroup.php:156 ../lib/plugin/PageGroup.php:167
284 #: ../lib/plugin/PageGroup.php:183 ../lib/plugin/PageGroup.php:190
285 #: ../lib/plugin/PageHistory.php:216 ../lib/plugin/UnfoldSubpages.php:164
286 #: ../themes/default/templates/head.tmpl:46
287 #, c-format
288 msgid "%s: %s"
289 msgstr "%s : %s"
290
291  6. To update the compiled translation files (phpwiki.mo and
292     phpwiki.php):
293
294       make
295
296 Make will then automatically generate and update all the necessary
297 files. If this step fails because you don't have the necessary
298 software installed, then send your '.po' files to one of the PhpWiki
299 developers who will run Makefile for you.
300
301
302 NOTE: "Fuzzy" translations will NOT be included in the final '.mo' and
303 'phpwiki.php' files. If you are not using the emacs editor, make sure
304 to remove the fuzzy marks from any *completed translations* before you
305 run the makefile, like this:
306
307     #: ../lib/plugin/BackLinks.php:44
308     #, fuzzy, c-format
309     msgid "These pages link to %s:"
310     msgstr "%d pages pointent vers %s."
311
312 should become:
313
314     #: ../lib/plugin/BackLinks.php:44
315     #, c-format
316     msgid "These pages link to %s:"
317     msgstr "%d pages pointent vers %s."
318
319 and...
320
321     #: ../lib/Toolbar.php:160 ../templates/browse.html:54
322     #, fuzzy
323     msgid "Lock page"
324     msgstr "Bloquear página"
325
326 should become:
327
328     #: ../lib/Toolbar.php:160 ../templates/browse.html:54
329     msgid "Lock page"
330     msgstr "Bloquear página"
331
332
333 HTML Templates
334 --------------
335 The template files do not need to be translated. As of PhpWiki 1.3 all
336 the text strings in the html templates are cross-referenced with the
337 translations in the '.po' files.
338
339 *** Note: Updating html template translations from PhpWiki 1.2 to 1.3: ***
340
341 The translated version of the tips for TextFormattingRules must be
342 moved from the old html template 'editpage.html', and placed into the
343 'pgsrc' for the default page of TextFormattingRules. A plugin now
344 extracts this text and inserts it when editing a page in PhpWiki,
345 rather than it being embedded within the html template itself.
346
347 It is suggested this paragraph would go at the top of the page. It
348 must be in a section heading entitled "Summary" in order for the
349 editpage template to find it. Of course you will substitute the
350 translations for "TextFormattingRules" and "Summary", according to the
351 wording you used for these phrases when you translated the '.po' file.
352
353 Refer to the English "TextFormattingRules" and German (de)
354 "TextFormatierungsRegeln" pages to see working examples.
355
356
357 Finale
358 ======
359 After you have finished translating, you will want to see the result
360 of your efforts. Change the $LANG setting in 'index.php' to the
361 two-letter code for your language.
362
363 Et voilà, Phpwiki should now speak Islandic!
364
365 If your translation was a success, you may also want to add a
366 translation of these instructions for translating PhpWiki ;-)
367
368 About gettext
369 -------------
370 To learn more about GNU gettext and '.po' files, you may find some
371 information at:
372
373     <http://www.iro.umontreal.ca/contrib/po/HTML/>
374     <http://www.gnu.org/directory/gettext>
375
376 Good luck,
377 Jan Nieuwenhuizen <janneke@gnu.org>
378 Arno Hollosi <ahollosi@mail.com>
379 Carsten Klapp <carstenklapp@users.sourceforge.net>
380
381 $Id: README,v 1.12 2004-06-19 12:13:57 rurban Exp $