cf7a458c72a46e5e291bbba65e3cfd9219262d39
[ikiwiki.git] / doc / plugins / contrib / linguas.mdwn
1 [[template id=plugin name=linguas author="Jordà Polo"]]
2
3 Linguas
4 =======
5
6 Linguas is a plugin for [ikiwiki](http://ikiwiki.kitenet.net/) that
7 allows translations of wiki pages.
8
9 Download: [linguas.pm](http://wiki.ettin.org/files/linguas.pm) (2006-08-21).
10
11 Usage
12 -----
13
14 Translatable pages and translations must have the following format:
15 `pagename.$LANG`, where `$LANG` is a ISO639-1 (two-letter) language code.
16 To enable linguas, add the following line in the source code of the page:
17
18         \[[linguas ]]
19
20 Note that linguas is only required in one of the pages (the original,
21 for instance); the rest of translations will be automatically
22 updated. Additionally, it is also possible to specify the title of
23 the translation:
24
25         \[[linguas title="Translated title"]]
26
27
28 Template
29 --------
30
31 This is the template code that should be added to `templates/page.tmpl`:
32
33         <TMPL_IF NAME="LINGUAS">
34         <div id="linguas">
35         <p class="otherlinguas"><TMPL_VAR NAME="OTHERLINGUAS"></p>
36         <ul>
37         <TMPL_LOOP NAME="LINGUAS">
38         <li><TMPL_VAR NAME=LINK></li>
39         </TMPL_LOOP>
40         </ul>
41         </div>
42         </TMPL_IF>
43
44
45 TODO/Known Problems
46 -------------------
47
48 * The current language list only contains 4 languages (ca, de, en,
49 es), and is "hardcoded" in linguas.pm. Would be interesting to define
50 it in ikiwiki.setup, though some problems were found while trying to do
51 so. (Actually, defining hash-like arguments from the command like works
52 fine, but it fails from ikiwiki.setup.)
53
54   > My guess about this is that it's because of the way Setup/Standard.pm
55   > untaints the config items from the file. It has code to handle arrays,
56   > but not hashes or more complex data structures. --[[Joey]]
57
58   >  > Right. With this simple
59   >  > [patch](http://wiki.ettin.org/files/hash_setup.patch) it seems to
60   >  > work. However, note that 1) it only allows simple hashes, hashes of
61   >  > hashes will not work (I don't think getops can handle complex hashes
62   >  > anyway); 2) I don't really know when/why you call
63   >  > `possibly_foolish_untaint()`; and 3) I'm no perl guru ;). --Jordà
64
65   >  >  > It's good. Applied..
66
67 * Wiki links to other translated pages require the full page name
68 including the `.$LANG`. It should be possible to link automatically
69 to pages with the same `.$LANG`, but that would probably require some
70 changes in IkiWiki. (I'm not sure though, I still haven't looked at
71 it... any hints?)
72
73   > Have you considered using the form ll/page? This would let more usual
74   > linking rules  apply amoung pages without needing to specify the
75   > language. I'm not sure if you're supporting browser content
76   > negotiation, or whether that other layout would be harder to support it
77   > though. --[[Joey]]
78
79   >  > Actually, I'm happy with the way it works now (and yeah, it is very
80   >  > easy to take advantage of content negotiation). I just wanted
81   >  > something simple to translatte a single page (or a few pages), not
82   >  > the entire wiki. I'm not even sure it is a good idea to have fully
83   >  > multilingual wikis, in most cases I would go for a different wiki
84   >  > for each language. That said, I think it is an interesting idea, so
85   >  > I'll take a look when I have the time. Thanks for your comments.
86   >  > --Jordà
87
88 Examples
89 --------
90
91 * [Linguas](http://wiki.ettin.org/linguas.en.html). A page with the same
92 content than this one.
93
94 * [Hello in some languages](http://wiki.ettin.org/hello/hello.en.html). The
95 translations were taken from [Hello in many
96 languages](http://www.omniglot.com/language/phrases/hello.htm) and from
97 the [Debian](http://www.debian.org/) website.