]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/po.mdwn
po plugin: switch to page.LL.html naming convention
[ikiwiki.git] / doc / plugins / po.mdwn
1 [[!template id=plugin name=po core=0 author="[[intrigeri]]"]]
2 [[!tag type/format]]
3
4 This plugin adds support for multi-lingual wikis, translated with
5 gettext, using [po4a](http://po4a.alioth.debian.org/).
6
7 It depends on the Perl `Locale::Po4a::Po` library (`apt-get install po4a`).
8
9 Introduction
10 ============
11
12 A language is chosen as the "master" one, and any other supported
13 language is a "slave" one. A page written in the "master" language is
14 a "master" page, and is written in any supported format but PO.
15
16 Example: `bla/page.mdwn` is a "master" Markdown page written in
17 English; if `usedirs` is enabled, it is rendered as
18 `bla/page/index.en.html`, else as `bla/page.en.html`.
19
20 Any translation of a "master" page into a "slave" language is called
21 a "slave" page; it is written in the gettext PO format. PO is now
22 a page type supported by ikiwiki.
23
24 Example: `bla/page.fr.po` is the PO "message catalog" used to
25 translate `bla/page.mdwn` into French; if `usedirs` is enabled, it is
26 rendered as `bla/page/index.fr.html`, else as `bla/page.fr.html`
27
28
29 Configuration
30 =============
31
32 `po_master_language` is used to set the master language in
33 `ikiwiki.setup`, such as:
34
35         po_master_language => { 'code' => 'en', 'name' => 'English' }
36
37 `po_slave_languages` is used to set the list of supported "slave"
38 languages, such as:
39
40         po_slave_languages => { 'fr' => { 'name' => 'Français', },
41                                 'es' => { 'name' => 'Castellano', },
42                                 'de' => { 'name' => 'Deutsch', }
43         }
44
45
46 Server support
47 ==============
48
49 Apache
50 ------
51
52 Using `mod_negotiation` makes it really easy to have Apache serve the
53 page in the client's preferred language, if available. This is the
54 default Debian Apache configuration.
55
56 When `usedirs` is enabled, one has to set `DirectoryIndex index` for
57 the wiki context.
58
59 Setting `DefaultLanguage LL` (replace `LL` with your default MIME
60 language) for the wiki context can be needed, to ensure
61 `bla/page/index.en.html` is served as `Content-Language: LL`.
62 **FIXME**: is it still needed with the new `.en.html` naming convention?
63
64 lighttpd
65 --------
66
67 lighttpd unfortunately does not support content negotiation.
68
69 **FIXME**: does `mod_magnet` provide the functionality needed to
70  emulate this?
71
72
73 TODO
74 ====
75
76 Display available translations
77 ------------------------------
78
79 The [[linguas|plugins/contrib/linguas]] plugin has some code that can
80 be used as a basis to display the existing translations, and allow to
81 navigate between them.
82
83 View translation status
84 -----------------------
85
86 One should be able to view some information about the translation
87 completeness, either for a given page or for the whole wiki.
88
89 This should not be too hard using gettext tools. If this is
90 implemented as a
91 [[HTML::Template|http://search.cpan.org/search?mode=dist&query=HTML%3A%3ATemplate]]
92 loop, a page using it should depend on any "master" and "slave" pages
93 whose status is being displayed.
94
95 Decide which pages are translatable
96 -----------------------------------
97
98 The subset of "master" pages subject to translation must be
99 configurable:
100
101 - a `[[!translatable ]]` directive, when put on a page, makes it
102   translatable
103 - to set at once a bunch of pages as being translatable, use this
104   [[ikiwiki/directive]] with the `match=PageSpec` argument.
105
106 Automatic PO files update
107 -------------------------
108
109 Committing changes to a "master" page must:
110
111 1. update the POT file and the PO files for the supported languages,
112    before putting them under version control
113 2. trigger a refresh of the corresponding HTML slave pages
114
115 The former is to be done at a time when:
116
117 - we know which "master" page was modified, and thus, which POT/PO
118   files have to be updated: the `needsbuild` hook is the first one to
119   run that provides us with the necessary information
120 - we can modify the list of pages needing a refresh; this is
121   `needsbuild` hook's job
122
123 The latter can be implemented by making any "slave" page depend on the
124 corresponding "master" page. The `add_depends` function can achieve
125 this, if used in a **FIXME** hook.
126
127 UI consistency: rename "Edit" button on slave pages
128 ---------------------------------------------------
129
130 It may be surprising to some, after having pressed *Edit* on a wiki
131 page, to end up editing a strange looking PO file. The *Edit* button
132 displayed on "slave" pages must therefore be renamed *Improve
133 translation* .
134
135 Pages selection depending on language
136 -------------------------------------
137
138 To improve user navigation in a multi-lingual wiki, site developers
139 must be enabled to write:
140
141         \[[!map pages="dev/* and preferredlang()" feeds="no"]]
142
143         \[[!map pages="dev/* and currentlang()" feeds="no"]]
144
145 Some new [[ikiwiki/pagespec]] functions have to be written.
146
147 Translation quality assurance
148 -----------------------------
149
150 Modifying a PO file via the CGI must only be allowed if the new
151 version is a valid PO file. As a bonus, check that it provides a more
152 complete translation than the existing one.
153
154 A new `cansave` type of hook would be needed to implement this.
155
156 Note: committing to the underlying repository is a way to bypass
157 this check.
158
159 Translating online
160 ------------------
161
162 As PO is a wiki page type, we already have an online PO editor, that
163 is ikiwiki's CGI.
164
165 A message-by-message interface could also be implemented at some
166 point; a nice way to do offline translation work (without VCS access)
167 still has to be offered, though.
168
169 Translating offline without VCS access
170 --------------------------------------
171
172 The following workflow should be made possible for translators without
173 VCS access who need to edit the PO files in another editor than a web
174 browser:
175
176 - download the page's PO file
177 - use any PO editor to update the translation
178 - upload the updated PO file
179
180 Implementation note: a generic mechanism to upload a page's source is
181 needed: it's only an alternative way to allow saving a the modified
182 page's source with the CGI.
183
184 ### Short-term workflow
185
186 A possible workaround is:
187
188 - pretend to edit the PO file online
189 - copy the PO file content from the textarea
190 - cancel the edit
191 - paste the content into a local file.
192 - edit the local file in any PO editor
193 - pretend to edit the PO file online
194 - paste the modified local file's content into the edit textarea
195 - save