]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/plugins/po.mdwn
po plugin: rewrite internal linking specification
[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.
15 A page written in the "master" language is a "master" page, and is
16 written in any supported format but PO. It does not have to be named
17 a special way: migration from/to this plugin does not imply heavy
18 renaming work.
20 Example: `bla/page.mdwn` is a "master" Markdown page written in
21 English; if `usedirs` is enabled, it is rendered as
22 `bla/page/index.en.html`, else as `bla/page.en.html`.
24 Any translation of a "master" page into a "slave" language is called
25 a "slave" page; it is written in the gettext PO format. PO is now
26 a page type supported by ikiwiki.
28 Example: `bla/page.fr.po` is the PO "message catalog" used to
29 translate `bla/page.mdwn` into French; if `usedirs` is enabled, it is
30 rendered as `bla/page/index.fr.html`, else as `bla/page.fr.html`
33 Configuration
34 =============
36 `po_master_language` is used to set the master language in
37 `ikiwiki.setup`, such as:
39         po_master_language => { 'code' => 'en', 'name' => 'English' }
41 `po_slave_languages` is used to set the list of supported "slave"
42 languages, such as:
44         po_slave_languages => { 'fr' => { 'name' => 'Français', },
45                                 'es' => { 'name' => 'Castellano', },
46                                 'de' => { 'name' => 'Deutsch', }
47         }
50 Server support
51 ==============
53 Apache
54 ------
56 Using `mod_negotiation` makes it really easy to have Apache serve the
57 page in the client's preferred language, if available. This is the
58 default Debian Apache configuration.
60 When `usedirs` is enabled, one has to set `DirectoryIndex index` for
61 the wiki context.
63 Setting `DefaultLanguage LL` (replace `LL` with your default MIME
64 language) for the wiki context can be needed, to ensure
65 `bla/page/index.en.html` is served as `Content-Language: LL`.
66 **FIXME**: is it still needed with the new `.en.html` naming convention?
68 lighttpd
69 --------
71 lighttpd unfortunately does not support content negotiation.
73 **FIXME**: does `mod_magnet` provide the functionality needed to
74  emulate this?
77 TODO
78 ====
80 Internal links
81 --------------
83 One can use the `po_link_to_` option in `ikiwiki.setup` to choose how
84 internal links should be generated, depending on web server features
85 and site-specific preferences.
87 ### Default linking behavior
89 If `po_link_to` is unset, or set to `default`, ikiwiki's default
90 linking behavior is preserved: `[[page]]` links to the master
91 language's page.
93 ### Link to negotiated language
95 If `po_link_to` is set to `negotiated`, `[[page]]` links to the
96 negotiated preferred language, *i.e.* `foo/page/`.
98 (In)compatibility notes:
100 - `po_link_to => negotiated` provides no useful behavior if `usedirs`
101   is disabled: 
102 - `po_link_to => negotiated` provides no useful behavior if the web
103   server does not support Content Negotiation
105 ### Link to current language
107 If `po_link_to` is set to `current` and the destination page is either
108 a translatable page or a translation, `[[page]]` links to the current
109 page's language, *i.e.*:
111 - `foo/page/index.LL.html` if `usedirs` is enabled
112 - `foo/page.LL.html` if `usedirs` is disabled
114 Display available translations
115 ------------------------------
117 The [[linguas|plugins/contrib/linguas]] plugin has some code that can
118 be used as a basis to display the existing translations, and allow to
119 navigate between them.
121 View translation status
122 -----------------------
124 One should be able to view some information about the translation
125 completeness, either for a given page or for the whole wiki.
127 This should not be too hard using gettext tools. If this is
128 implemented as a
129 [[HTML::Template|http://search.cpan.org/search?mode=dist&query=HTML%3A%3ATemplate]]
130 loop, a page using it should depend on any "master" and "slave" pages
131 whose status is being displayed.
133 Decide which pages are translatable
134 -----------------------------------
136 The subset of "master" pages subject to translation must be
137 configurable:
139 - a `[[!translatable ]]` directive, when put on a page, makes it
140   translatable
141 - to set at once a bunch of pages as being translatable, use this
142   [[ikiwiki/directive]] with the `match=PageSpec` argument.
144 Automatic PO files update
145 -------------------------
147 Committing changes to a "master" page must:
149 1. update the POT file and the PO files for the supported languages,
150    before putting them under version control
151 2. trigger a refresh of the corresponding HTML slave pages
153 The former is to be done at a time when:
155 - we know which "master" page was modified, and thus, which POT/PO
156   files have to be updated: the `needsbuild` hook is the first one to
157   run that provides us with the necessary information
158 - we can modify the list of pages needing a refresh; this is
159   `needsbuild` hook's job
161 The latter can be implemented by making any "slave" page depend on the
162 corresponding "master" page. The `add_depends` function can achieve
163 this, if used in a **FIXME** hook.
165 UI consistency: rename "Edit" button on slave pages
166 ---------------------------------------------------
168 It may be surprising to some, after having pressed *Edit* on a wiki
169 page, to end up editing a strange looking PO file. The *Edit* button
170 displayed on "slave" pages must therefore be renamed *Improve
171 translation* .
173 Pages selection depending on language
174 -------------------------------------
176 To improve user navigation in a multi-lingual wiki, site developers
177 must be enabled to write:
179         \[[!map pages="dev/* and lang(LL)" feeds="no"]]
181         \[[!map pages="dev/* and currentlang()" feeds="no"]]
183 Translation quality assurance
184 -----------------------------
186 Modifying a PO file via the CGI must only be allowed if the new
187 version is a valid PO file. As a bonus, check that it provides a more
188 complete translation than the existing one.
190 A new `cansave` type of hook would be needed to implement this.
192 Note: committing to the underlying repository is a way to bypass
193 this check.
195 Translating online
196 ------------------
198 As PO is a wiki page type, we already have an online PO editor, that
199 is ikiwiki's CGI.
201 A message-by-message interface could also be implemented at some
202 point; a nice way to do offline translation work (without VCS access)
203 still has to be offered, though.
205 Translating offline without VCS access
206 --------------------------------------
208 The following workflow should be made possible for translators without
209 VCS access who need to edit the PO files in another editor than a web
210 browser:
212 - download the page's PO file
213 - use any PO editor to update the translation
214 - upload the updated PO file
216 Implementation note: a generic mechanism to upload a page's source is
217 needed: it's only an alternative way to allow saving a the modified
218 page's source with the CGI.
220 ### Short-term workflow
222 A possible workaround is:
224 - pretend to edit the PO file online
225 - copy the PO file content from the textarea
226 - cancel the edit
227 - paste the content into a local file.
228 - edit the local file in any PO editor
229 - pretend to edit the PO file online
230 - paste the modified local file's content into the edit textarea
231 - save