]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/linguas.mdwn
0d05c08648b862eeef3f322be88d4acd309ec4e5
[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.info/) 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 * The changes to htmllink in ikiwiki 1.44 broke this plugin.
89 The following fixes it:
90
91         --- linguas.pm.orig     2006-08-23 19:07:04.000000000 +0200
92         +++ linguas.pm  2007-03-24 01:53:18.000000000 +0100
93         @@ -100,7 +100,7 @@
94                         if (exists $linguas{$2} && defined $linguas{$2}) {
95                                 $link = $linguas{$2}{'name'};
96                         }
97         -               push @links, IkiWiki::htmllink($page, $destpage, $trans, 0, 0, $link);
98         +               push @links, IkiWiki::htmllink($page, $destpage, $trans, noimageinline => 0, forcesubpage => 0, linktext => $link);
99                 }
100          
101                 my $otherlinguas = 'Translations:';
102
103
104 Examples
105 --------
106
107 * [Linguas](http://wiki.ettin.org/linguas.en.html). A page with the same
108 content than this one.
109
110 * [Hello in some languages](http://wiki.ettin.org/hello/hello.en.html). The
111 translations were taken from [Hello in many
112 languages](http://www.omniglot.com/language/phrases/hello.htm) and from
113 the [Debian](http://www.debian.org/) website.