]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po plugin: added and documented PERCENTTRANSLATED template variable
authorintrigeri <intrigeri@boum.org>
Wed, 15 Oct 2008 00:25:34 +0000 (02:25 +0200)
committerintrigeri <intrigeri@boum.org>
Sat, 18 Oct 2008 13:49:12 +0000 (15:49 +0200)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm
doc/plugins/po.mdwn

index eee6d40583a0e99e8a14ecd20d1ef6fe537a1729..98c070481978a560d328ecc107dac4396d3a341e 100644 (file)
@@ -18,6 +18,7 @@ use Memoize;
 my %translations;
 memoize("istranslatable");
 memoize("_istranslation");
+memoize("percenttranslated");
 
 sub import {
        hook(type => "getsetup", id => "po", call => \&getsetup);
@@ -318,6 +319,9 @@ sub pagetemplate (@) { #{{{
         my $page=$params{page};
         my $template=$params{template};
 
+       if (istranslation($page) && $template->query(name => "percenttranslated")) {
+               $template->param(percenttranslated => percenttranslated($page));
+       }
        if ($template->query(name => "otherlanguages")) {
                $template->param(otherlanguages => [otherlanguages($page)]);
        }
index ab37ae419befcbfb0d36cc489ed3d7565b532033..02e6ca76687abbd44bd288981858d931f12c0ca3 100644 (file)
@@ -126,6 +126,8 @@ Usage
 Templates
 ---------
 
+### Display page's versions in other languages
+
 The `OTHERLANGUAGES` loop provides ways to display other languages'
 versions of the same page, and the translations' status.
 
@@ -154,6 +156,11 @@ The following variables are available inside the loop (for every page in):
 - `MASTER` - is true (1) if, and only if the page is a "master" page
 - `PERCENT` - for "slave" pages, is set to the translation completeness, in percents
 
+### Display the current translation status
+
+The `PERCENTTRANSLATED` variable is set to the translation
+completeness, expressed in percent, on "slave" pages.
+
 Additional PageSpec tests
 -------------------------
 
@@ -164,27 +171,16 @@ additional tests that are documented [[here|ikiwiki/pagespec/po]].
 TODO
 ====
 
-Link relationships
-------------------
+OTHERLANGUAGES dependencies
+---------------------------
 
-Should pages using the `OTHERLANGUAGES` template loop be declared as
-linking to the same page in other versions?
+Pages using `OTHERLANGUAGES` must depend on any "master" and "slave"
+pages whose status is being displayed. It will trigger dependency
+loops; how to sort this out?
 
-View translation status
------------------------
-
-One should be able to view some information about the translation
-completeness, either for a given page or for the whole wiki.
-
-This should not be too hard using gettext tools. If this is
-implemented as a
-[HTML::Template](http://search.cpan.org/search?mode=dist&query=HTML%3A%3ATemplate)
-loop, a page using it should depend on any "master" and "slave" pages
-whose status is being displayed.
-
-If it's not too heavy to compute, this status data may be made
-available in the `OTHERLANGUAGES` template loop; else, a dedicated
-loop would be needed.
+Should pages using the `OTHERLANGUAGES` template loop be declared as
+linking to the same page in other versions? To be rigorous, they
+should, but this may clutter the backlinks.
 
 Automatic PO files update
 -------------------------