From: intrigeri Date: Wed, 15 Oct 2008 00:25:34 +0000 (+0200) Subject: po plugin: added and documented PERCENTTRANSLATED template variable X-Git-Tag: 3.15~426 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/6add615928581ddacd03b01de126fb098d1a8eda?ds=inline po plugin: added and documented PERCENTTRANSLATED template variable Signed-off-by: intrigeri --- diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index eee6d4058..98c070481 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -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)]); } diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index ab37ae419..02e6ca766 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -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 -------------------------