1 [[!template id=plugin name=po core=0 author="[[intrigeri]]"]]
4 This plugin adds support for multi-lingual wikis, translated with
5 gettext, using [po4a](http://po4a.alioth.debian.org/).
7 It depends on the Perl `Locale::Po4a::Po` library (`apt-get install po4a`).
8 As detailed bellow in the security section, `po4a` is subject to
9 denial-of-service attacks before version 0.35.
16 A language is chosen as the "master" one, and any other supported
17 language is a "slave" one.
19 A page written in the "master" language is a "master" page. It can be
20 of any page type supported by ikiwiki, except `po`. It does not have to be
21 named a special way: migration to this plugin does not imply any page
24 Example: `bla/page.mdwn` is a "master" Markdown page written in
25 English; if `usedirs` is enabled, it is rendered as
26 `bla/page/index.en.html`, else as `bla/page.en.html`.
28 Any translation of a "master" page into a "slave" language is called
29 a "slave" page; it is written in the gettext PO format. `po` is now
30 a page type supported by ikiwiki.
32 Example: `bla/page.fr.po` is the PO "message catalog" used to
33 translate `bla/page.mdwn` into French; if `usedirs` is enabled, it is
34 rendered as `bla/page/index.fr.html`, else as `bla/page.fr.html`
39 This plugin does not support the `indexpages` mode. If you don't know
40 what it is, you probably don't care.
49 `po_master_language` is used to set the "master" language in
50 `ikiwiki.setup`, such as:
52 po_master_language => { 'code' => 'en', 'name' => 'English' }
54 `po_slave_languages` is used to set the list of supported "slave"
57 po_slave_languages => [ 'fr|Français',
62 Decide which pages are translatable
63 -----------------------------------
65 The `po_translatable_pages` setting configures what pages are
66 translatable. It is a [[ikiwiki/PageSpec]], so you have lots of
67 control over what kind of pages are translatable.
69 The `.po` files are not considered as being translatable, so you don't need to
70 worry about excluding them explicitly from this [[ikiwiki/PageSpec]].
77 The `po_link_to` option in `ikiwiki.setup` is used to decide how
78 internal links should be generated, depending on web server features
79 and site-specific preferences.
81 #### Default linking behavior
83 If `po_link_to` is unset, or set to `default`, ikiwiki's default
84 linking behavior is preserved: `\[[destpage]]` links to the master
87 #### Link to current language
89 If `po_link_to` is set to `current`, `\[[destpage]]` links to the
90 `destpage`'s version written in the current page's language, if
93 * `foo/destpage/index.LL.html` if `usedirs` is enabled
94 * `foo/destpage.LL.html` if `usedirs` is disabled
96 #### Link to negotiated language
98 If `po_link_to` is set to `negotiated`, `\[[page]]` links to the
99 negotiated preferred language, *i.e.* `foo/page/`.
101 (In)compatibility notes:
103 * if `usedirs` is disabled, it does not make sense to set `po_link_to`
104 to `negotiated`; this option combination is neither implemented
106 * if the web server does not support Content Negotiation, setting
107 `po_link_to` to `negotiated` will produce a unusable website.
115 Using Apache `mod_negotiation` makes it really easy to have Apache
116 serve any page in the client's preferred language, if available.
118 Add 'Options MultiViews' to the wiki directory's configuration in Apache.
120 When `usedirs` is enabled, one has to set `DirectoryIndex index` for
123 Setting `DefaultLanguage LL` (replace `LL` with your default MIME
124 language code) for the wiki context can help to ensure
125 `bla/page/index.en.html` is served as `Content-Language: LL`.
127 For details, see [Apache's documentation](http://httpd.apache.org/docs/2.2/content-negotiation.html).
132 Recent versions of lighttpd should be able to use
133 `$HTTP["language"]` to configure the translated pages to be served.
135 See [Lighttpd Issue](http://redmine.lighttpd.net/issues/show/1119)
145 When `po_link_to` is not set to `negotiated`, one should replace some
146 occurrences of `BASEURL` with `HOMEPAGEURL` to get correct links to
149 The `ISTRANSLATION` and `ISTRANSLATABLE` variables can be used to
150 display things only on translatable or translation pages.
152 ### Display page's versions in other languages
154 The `OTHERLANGUAGES` loop provides ways to display other languages'
155 versions of the same page, and the translations' status.
157 An example of its use can be found in the default
158 `templates/page.tmpl`. In case you want to customize it, the following
159 variables are available inside the loop (for every page in):
161 * `URL` - url to the page
162 * `CODE` - two-letters language code
163 * `LANGUAGE` - language name (as defined in `po_slave_languages`)
164 * `MASTER` - is true (1) if, and only if the page is a "master" page
165 * `PERCENT` - for "slave" pages, is set to the translation completeness, in percents
167 ### Display the current translation status
169 The `PERCENTTRANSLATED` variable is set to the translation
170 completeness, expressed in percent, on "slave" pages. It is used by
171 the default `templates/page.tmpl`.
173 Additional PageSpec tests
174 -------------------------
176 This plugin enhances the regular [[ikiwiki/PageSpec]] syntax with some
177 additional tests that are documented [[here|ikiwiki/pagespec/po]].
179 Automatic PO file update
180 ------------------------
182 Committing changes to a "master" page:
184 1. updates the POT file and the PO files for the "slave" languages;
185 the updated PO files are then put under version control;
186 2. triggers a refresh of the corresponding HTML slave pages.
188 Also, when the plugin has just been enabled, or when a page has just
189 been declared as being translatable, the needed POT and PO files are
190 created, and the PO files are checked into version control.
192 Discussion pages and other sub-pages
193 ------------------------------------
195 Discussion should happen in the language in which the pages are
196 written for real, *i.e.* the "master" one. If discussion pages are
197 enabled, "slave" pages therefore link to the "master" page's
200 Likewise, "slave" pages are not supposed to have sub-pages;
201 [[WikiLinks|wikilink]] that appear on a "slave" page therefore link to
202 the master page's sub-pages.
207 One can edit the PO files using ikiwiki's CGI (a message-by-message
208 interface could also be implemented at some point).
210 If [[tips/untrusted_git_push]] is setup, one can edit the PO files in one's
211 preferred `$EDITOR`, without needing to be online.
213 Markup languages support
214 ------------------------
216 [[Markdown|mdwn]] and [[html]] are well supported. Some other markup
217 languages supported by ikiwiki mostly work, but some pieces of syntax
218 are not rendered correctly on the slave pages:
220 * [[reStructuredText|rst]]: anonymous hyperlinks and internal
222 * [[wikitext]]: conversion of newlines to paragraphs
223 * [[creole]]: verbatim text is wrapped, tables are broken
224 * LaTeX: not supported yet; the dedicated po4a module
225 could be used to support it, but it would need a security audit
226 * other markup languages have not been tested.
231 [[po/discussion]] contains a detailed security analysis of this plugin
232 and its dependencies.
234 When using po4a older than 0.35, it is recommended to uninstall
235 `Text::WrapI18N` (Debian package `libtext-wrapi18n-perl`), in order to
236 avoid a potential denial of service.
241 [[!map pages="bugs/po:*"]]
243 [[!inline pages="bugs/po:* and !bugs/done and !link(bugs/done) and !bugs/*/*"
244 feeds=no actions=no archive=yes show=0]]
249 [[!inline pages="todo/po:* and !todo/done and !link(todo/done) and !todo/*/*"
250 feeds=no actions=no archive=yes show=0]]
252 l10n wiki misconfiguration
253 --------------------------
255 If a page is not translated yet, the "translated" version of it
256 displays wikilinks to other, existing (but not yet translated?)
257 pages as edit links, as if those pages do not exist.
259 That's really confusing, especially as clicking such a link
260 brings up an edit form to create a new, english page.
262 This is with po_link_to=current or negotiated. With default, it doesn't
265 Also, this may only happen if the page being linked to is coming from an
266 underlay, and the underlays lack translation to a given language.
269 > Any simple testcase to reproduce it, please? I've never seen this
270 > happen yet. --[[intrigeri]]
272 >> Sure, go here <http://l10n.ikiwiki.info/smiley/smileys/index.sv.html>
273 >> (Currently 0% translateed) and see the 'WikiLink' link at the bottom,
274 >> which goes to <http://l10n.ikiwiki.info/ikiwiki.cgi?page=ikiwiki/wikilink&from=smiley/smileys&do=create>
275 >> Compare with eg, the 100% translated Dansk version, where
276 >> the WikiLink link links to the English WikiLink page. --[[Joey]]
278 >>> Seems not related to the page/string translation status: the 0%
279 >>> translated Spanish version has the correct link, just like the
280 >>> Dansk version => I'm changing the bug title accordingly.
282 >>> I tested forcing the sv html page to be rebuilt by translating a
283 >>> string in it, it did not fix the bug. I did the same for the
284 >>> Spanish page, it did not introduce the bug. So this is really
287 >>> The smiley underlay seems to be the only place where the wrong
288 >>> thing happens: the basewiki underlay has similar examples
289 >>> that do not exhibit this bug. An underlay linking to another might
290 >>> be necessary to reproduce it. Going to dig deeper. --[[intrigeri]]
292 >>>> After a few hours lost in the Perl debugger, I think I have found
293 >>>> the root cause of the problem: in l10n wiki's configured
294 >>>> `underlaydir`, the basewiki is present in every slave language
295 >>>> that is enabled for this wiki *but* Swedish. With such a
296 >>>> configuration, the `ikiwiki/wikilink` page indeed does not exist
297 >>>> in Swedish language: no `ikiwiki/wikilink.sv.po` can be found
298 >>>> where ikiwiki is looking. Have a look to
299 >>>> <http://l10n.ikiwiki.info/ikiwiki/>, the basewiki is not
300 >>>> available in Swedish language on this wiki. So this is not a po
301 >>>> bug, but a configuration or directories layout issue. This is
302 >>>> solved by adding the Swedish basewiki to the underlay dir, which
303 >>>> is I guess not a possibility in the l10n wiki context. I guess
304 >>>> this could be solved by adding `SRCDIR/basewiki` as an underlay
305 >>>> to your l10n wiki configuration, possibly using the
306 >>>> `add_underlays` configuration directive. --[[intrigeri]]