]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/plugins/po.mdwn
9e9ba1fd841631ce6204a834229ca908050d05cf
[git.ikiwiki.info.git] / doc / plugins / po.mdwn
1 [[!template id=plugin name=po core=0 author="[[intrigeri]]"]]
2 [[!tag type/format]]
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`).
9 Introduction
10 ============
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.
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`.
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.
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`
29 Configuration
30 =============
32 `po_master_language` is used to set the master language in
33 `ikiwiki.setup`, such as:
35         po_master_language => { 'code' => 'en', 'name' => 'English' }
37 `po_slave_languages` is used to set the list of supported "slave"
38 languages, such as:
40         po_slave_languages => { 'fr' => { 'name' => 'Français', },
41                                 'es' => { 'name' => 'Castellano', },
42                                 'de' => { 'name' => 'Deutsch', }
43         }
46 Server support
47 ==============
49 Apache
50 ------
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.
56 When `usedirs` is enabled, one has to set `DirectoryIndex index` for
57 the wiki context.
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?
64 lighttpd
65 --------
67 lighttpd unfortunately does not support content negotiation.
69 **FIXME**: does `mod_magnet` provide the functionality needed to
70  emulate this?
73 TODO
74 ====
76 Links
77 -----
79 Choice between two behaviors must be possible in `ikiwiki.setup`;
80 a `po_link_to_current_language` option must allow switching
81 between them.
83 If `po_link_to_current_language` is disabled, `[[page]]` links to the
84 negotiated preferred language, i.e.:
86 - `usedirs` enabled: `bla/page/`
87 - `usedirs` disabled: `bla/page`
89 This obviously does not work in case Content Negotiation is not
90 supported by the web server, hence one can enable
91 `po_link_to_current_language` to make `[[page]]` link to the current
92 page's language, i.e.:
94 - `usedirs` enabled: `bla/page/index.LL.html`
95 - `usedirs` disabled: `bla/page.LL.html`
97 **FIXME**: should `po_link_to_current_language` be enabled by default?
99 Display available translations
100 ------------------------------
102 The [[linguas|plugins/contrib/linguas]] plugin has some code that can
103 be used as a basis to display the existing translations, and allow to
104 navigate between them.
106 View translation status
107 -----------------------
109 One should be able to view some information about the translation
110 completeness, either for a given page or for the whole wiki.
112 This should not be too hard using gettext tools. If this is
113 implemented as a
114 [[HTML::Template|http://search.cpan.org/search?mode=dist&query=HTML%3A%3ATemplate]]
115 loop, a page using it should depend on any "master" and "slave" pages
116 whose status is being displayed.
118 Decide which pages are translatable
119 -----------------------------------
121 The subset of "master" pages subject to translation must be
122 configurable:
124 - a `[[!translatable ]]` directive, when put on a page, makes it
125   translatable
126 - to set at once a bunch of pages as being translatable, use this
127   [[ikiwiki/directive]] with the `match=PageSpec` argument.
129 Automatic PO files update
130 -------------------------
132 Committing changes to a "master" page must:
134 1. update the POT file and the PO files for the supported languages,
135    before putting them under version control
136 2. trigger a refresh of the corresponding HTML slave pages
138 The former is to be done at a time when:
140 - we know which "master" page was modified, and thus, which POT/PO
141   files have to be updated: the `needsbuild` hook is the first one to
142   run that provides us with the necessary information
143 - we can modify the list of pages needing a refresh; this is
144   `needsbuild` hook's job
146 The latter can be implemented by making any "slave" page depend on the
147 corresponding "master" page. The `add_depends` function can achieve
148 this, if used in a **FIXME** hook.
150 UI consistency: rename "Edit" button on slave pages
151 ---------------------------------------------------
153 It may be surprising to some, after having pressed *Edit* on a wiki
154 page, to end up editing a strange looking PO file. The *Edit* button
155 displayed on "slave" pages must therefore be renamed *Improve
156 translation* .
158 Pages selection depending on language
159 -------------------------------------
161 To improve user navigation in a multi-lingual wiki, site developers
162 must be enabled to write:
164         \[[!map pages="dev/* and lang(LL)" feeds="no"]]
166         \[[!map pages="dev/* and currentlang()" feeds="no"]]
168 Translation quality assurance
169 -----------------------------
171 Modifying a PO file via the CGI must only be allowed if the new
172 version is a valid PO file. As a bonus, check that it provides a more
173 complete translation than the existing one.
175 A new `cansave` type of hook would be needed to implement this.
177 Note: committing to the underlying repository is a way to bypass
178 this check.
180 Translating online
181 ------------------
183 As PO is a wiki page type, we already have an online PO editor, that
184 is ikiwiki's CGI.
186 A message-by-message interface could also be implemented at some
187 point; a nice way to do offline translation work (without VCS access)
188 still has to be offered, though.
190 Translating offline without VCS access
191 --------------------------------------
193 The following workflow should be made possible for translators without
194 VCS access who need to edit the PO files in another editor than a web
195 browser:
197 - download the page's PO file
198 - use any PO editor to update the translation
199 - upload the updated PO file
201 Implementation note: a generic mechanism to upload a page's source is
202 needed: it's only an alternative way to allow saving a the modified
203 page's source with the CGI.
205 ### Short-term workflow
207 A possible workaround is:
209 - pretend to edit the PO file online
210 - copy the PO file content from the textarea
211 - cancel the edit
212 - paste the content into a local file.
213 - edit the local file in any PO editor
214 - pretend to edit the PO file online
215 - paste the modified local file's content into the edit textarea
216 - save