]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/plugins/po.mdwn
6690e5deaf15adeea14ff907ab167aac2c41f7ec
[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 decided to be 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.html`, else as `bla/page.html`.
20 Translations of a "master" page into a "slave" language are called
21 "slave" pages, and is a in gettext PO format. PO is thus promoted to
22 the wiki page type status.
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.html.fr`, else as `bla/page.html.fr`
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` for the wiki context can be needed, to
60 ensure `bla/page/index.html` is served as `Content-Language: LL`
61 (replace `LL` with your default MIME language).
63 lighttpd
64 --------
66 lighttpd unfortunately does not support content negotiation.
69 TODO
70 ====
72 Display available translations
73 ------------------------------
75 The [[linguas|plugins/contrib/linguas]] plugin has some code that can
76 be used as a basis to display the existing translations, and allow to
77 navigate between them.
79 View translation status
80 -----------------------
82 One should be able to view some freshness information about the
83 translation status, either for a given page or for the whole wiki.
85 This should not be too hard using gettext tools. If this is
86 implemented as a
87 [[HTML::Template|http://search.cpan.org/search?mode=dist&query=HTML%3A%3ATemplate]]
88 loop, a page using it should depend on any "master" and "slave" pages
89 whose status is being displayed.
91 Decide which pages are translatable
92 -----------------------------------
94 The subset of ("master") pages supporting translation must be
95 configurable:
97 - a `[[!translatable ]]` directive, when put on a page, makes it
98   translatable
99 - this [[ikiwiki/directive]] can be used with an optional `match=PageSpec`
100   argument, to render translatable a bunch of pages at once
102 Automatic PO files update
103 -------------------------
105 Committing changes to a "master" page must:
107 1. update the POT file, the PO files for the supported languages, and
108    put them under version control
109 2. trigger a refresh of the corresponding HTML slave pages
111 The former can be implemented as a `needsbuild` hook, which is the
112 first type of hook to run after the list of files that need to be
113 built is known: that is, at a time when we know which "master" page
114 was modified, and thus, which POT/PO files have to be updated.
116 The latter can be implemented by making any "slave" page depend on the
117 corresponding "master" page. The `add_depends` function can achieved
118 this, if used in a FIXME hook.
120 UI consistency: rename "Edit" button on slave pages
121 ---------------------------------------------------
123 It may be surprising to some, after having pressed *Edit* on a wiki
124 page, to end up editing a strange PO file. The *Edit* button must then
125 be be renamed to *Improve translation* on "slave" pages.
127 Translation quality assurance
128 -----------------------------
130 Modifying a PO file via the CGI must only be allowed if the new
131 version is a valid PO file. As a bonus, check that it provides a more
132 complete translation than the existing one.
134 A new `cansave` type of hook would be needed to implement this.
136 Note: committing to the underlying repository is a way to bypass
137 this check.
139 Translating online
140 ------------------
142 As PO is a wiki page type, we already have an online PO editor, that
143 is ikiwiki's CGI.
145 A message-by-message interface could be implemented later, providing
146 a nice way to translate offline (without VCS access) is provided.
148 Translating offline without VCS access
149 --------------------------------------
151 The following workflow should be made possible for translators without
152 VCS access who need to edit the PO files in another editor than a web
153 browser:
155 - download the PO file for the page
156 - use any PO editor to update the translation
157 - upload the updated PO file
159 A generic mechanism to download and upload a page's source is needed.
160 It's only an alternative way to do Edit/edit/Save.
162 ### Short-term workflow
164 - pretend to edit the PO file online
165 - copy the PO file content from the textarea
166 - cancel the edit
167 - paste the content into a local file.