From 912521ef0711204965aa2319d41c7741bd3f4f4c Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 29 Dec 2006 04:38:40 +0000 Subject: * Initial work on internationalization of the program code. po/ikiwiki.pot is available for translation. * Export gettext() from IkiWiki module. --- IkiWiki/Plugin/aggregate.pm | 26 ++++++++++++++------------ IkiWiki/Plugin/brokenlinks.pm | 2 +- IkiWiki/Plugin/fortune.pm | 2 +- IkiWiki/Plugin/googlecalendar.pm | 2 +- IkiWiki/Plugin/img.pm | 2 -- IkiWiki/Plugin/inline.pm | 10 +++++----- IkiWiki/Plugin/linkmap.pm | 2 +- IkiWiki/Plugin/mdwn.pm | 2 +- IkiWiki/Plugin/mirrorlist.pm | 4 ++-- IkiWiki/Plugin/openid.pm | 4 ++-- IkiWiki/Plugin/orphans.pm | 2 +- IkiWiki/Plugin/passwordauth.pm | 10 +++++----- IkiWiki/Plugin/poll.pm | 4 ++-- IkiWiki/Plugin/polygen.pm | 6 +++--- IkiWiki/Plugin/search.pm | 6 +++--- IkiWiki/Plugin/shortcut.pm | 4 ++-- IkiWiki/Plugin/smiley.pm | 2 +- IkiWiki/Plugin/template.pm | 11 +++++------ 18 files changed, 50 insertions(+), 51 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index 2a3f36fce..46cd3102c 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -58,7 +58,7 @@ sub preprocess (@) { #{{{ foreach my $required (qw{name url}) { if (! exists $params{$required}) { - return "[[aggregate plugin missing $required parameter]]"; + return "[[".sprintf(gettext("aggregate plugin missing %s parameter"), $required)."]]"; } } @@ -86,7 +86,7 @@ sub preprocess (@) { #{{{ $feed->{lastupdate}=0 unless defined $feed->{lastupdate}; $feed->{numposts}=0 unless defined $feed->{numposts}; $feed->{newposts}=0 unless defined $feed->{newposts}; - $feed->{message}="new feed" unless defined $feed->{message}; + $feed->{message}=gettext("new feed") unless defined $feed->{message}; $feed->{error}=0 unless defined $feed->{error}; $feed->{tags}=[]; while (@_) { @@ -100,8 +100,9 @@ sub preprocess (@) { #{{{ return "{url}."\">".$feed->{name}.": ". ($feed->{error} ? "" : "").$feed->{message}. ($feed->{error} ? "" : ""). - " (".$feed->{numposts}." posts". - ($feed->{newposts} ? "; ".$feed->{newposts}." new" : ""). + " (".$feed->{numposts}." ".gettext("posts"). + ($feed->{newposts} ? "; ".$feed->{newposts}. + " ".gettext("new") : ""). ")"; } # }}} @@ -202,13 +203,14 @@ sub expire () { #{{{ if ($feed->{expireage}) { my $days_old = (time - $IkiWiki::pagectime{$item->{page}}) / 60 / 60 / 24; if ($days_old > $feed->{expireage}) { - debug("expiring ".$item->{page}." ($days_old days old)"); + debug(sprintf(gettext("expiring %s (%s days old)"), + $item->{page}, $days_old)); $item->{expired}=1; } } elsif ($feed->{expirecount} && $count >= $feed->{expirecount}) { - debug("expiring ".$item->{page}); + debug(sprintf(gettext("expiring %s"), $item->{page})); $item->{expired}=1; } else { @@ -231,12 +233,12 @@ sub aggregate () { #{{{ $feed->{newposts}=0; $IkiWiki::forcerebuild{$feed->{sourcepage}}=1; - debug("checking feed ".$feed->{name}." ..."); + debug(sprintf(gettext("checking feed %s ..."), $feed->{name})); if (! length $feed->{feedurl}) { my @urls=XML::Feed->find_feeds($feed->{url}); if (! @urls) { - $feed->{message}="could not find feed at ".$feed->{feedurl}; + $feed->{message}=sprintf(gettext("could not find feed at %s"), $feed->{feedurl}); $feed->{error}=1; debug($feed->{message}); next; @@ -245,7 +247,7 @@ sub aggregate () { #{{{ } my $f=eval{XML::Feed->parse(URI->new($feed->{feedurl}))}; if ($@) { - $feed->{message}="feed crashed XML::Feed! $@"; + $feed->{message}=gettext("feed crashed XML::Feed!")." ($@)"; $feed->{error}=1; debug($feed->{message}); next; @@ -268,8 +270,8 @@ sub aggregate () { #{{{ ); } - $feed->{message}="processed ok at ". - displaytime($feed->{lastupdate}); + $feed->{message}=sprintf(gettext("processed ok at "), + displaytime($feed->{lastupdate})); $feed->{error}=0; } } #}}} @@ -309,7 +311,7 @@ sub add_page (@) { #{{{ $c++ } $guid->{page}=$page; - debug("creating new page $page"); + debug(sprintf(gettext("creating new page %s"), $page)); } $guid->{feed}=$feed->{name}; diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index 6741f9081..e79ce1d81 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -33,7 +33,7 @@ sub preprocess (@) { #{{{ } } - return "There are no broken links!" unless @broken; + return gettext("There are no broken links!") unless @broken; my %seen; return "\n"; } # }}} diff --git a/IkiWiki/Plugin/fortune.pm b/IkiWiki/Plugin/fortune.pm index 4ff343e3a..3bab134be 100644 --- a/IkiWiki/Plugin/fortune.pm +++ b/IkiWiki/Plugin/fortune.pm @@ -15,7 +15,7 @@ sub preprocess (@) { #{{{ my $f = `fortune 2>/dev/null`; if ($?) { - return "[[fortune failed]]"; + return "[[".gettext("fortune failed")."]]"; } else { return "
$f
\n"; diff --git a/IkiWiki/Plugin/googlecalendar.pm b/IkiWiki/Plugin/googlecalendar.pm index dc0df0ad3..7620384f5 100644 --- a/IkiWiki/Plugin/googlecalendar.pm +++ b/IkiWiki/Plugin/googlecalendar.pm @@ -19,7 +19,7 @@ sub preprocess (@) { #{{{ # Avoid XSS attacks.. my ($url)=$params{html}=~m#iframe\s+src="http://www\.google\.com/calendar/embed\?([^"<>]+)"#; if (! defined $url || ! length $url) { - return "[[googlecalendar failed to find url in html]]"; + return "[[".gettext("googlecalendar failed to find url in html")."]]"; } my ($height)=$params{html}=~m#height="(\d+)"#; my ($width)=$params{html}=~m#width="(\d+)"#; diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 20893f56c..120326910 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -8,8 +8,6 @@ use strict; use IkiWiki; use Image::Magick; -my $convert = 'convert'; - my %imgdefaults; sub import { #{{{ diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 70b353ec5..eb21959f9 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -34,7 +34,7 @@ sub getopt () { #{{{ sub checkconfig () { #{{{ if (($config{rss} || $config{atom}) && ! length $config{url}) { - error("Must specify url to wiki with --url when using --rss or --atom"); + error(gettext("Must specify url to wiki with --url when using --rss or --atom")); } if ($config{rss}) { push @{$config{wiki_file_prune_regexps}}, qr/\.rss$/; @@ -94,7 +94,7 @@ sub preprocess_inline (@) { #{{{ @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list; } else { - return "unknown sort type $params{sort}"; + return sprintf(gettext("unknown sort type %s"), $params{sort}); } if (exists $params{skip}) { @@ -365,7 +365,7 @@ sub pingurl (@) { #{{{ eval q{require RPC::XML::Client}; if ($@) { - debug("RPC::XML::Client not found, not pinging"); + debug(gettext("RPC::XML::Client not found, not pinging")); return; } @@ -373,11 +373,11 @@ sub pingurl (@) { #{{{ defined(my $pid = fork) or error("Can't fork: $!"); return if $pid; chdir '/'; - eval q{use POSIX ’setsid’}; + eval q{use POSIX 'setsid'}; setsid() or error("Can't start a new session: $!"); open STDIN, '/dev/null'; open STDOUT, '>/dev/null'; - open STDERR, '>&STDOUT' or error("Can’t dup stdout: $!"); + open STDERR, '>&STDOUT' or error("Can't dup stdout: $!"); # Don't need to keep a lock on the wiki as a daemon. IkiWiki::unlockwiki(); diff --git a/IkiWiki/Plugin/linkmap.pm b/IkiWiki/Plugin/linkmap.pm index d7dffc941..e0c5fb475 100644 --- a/IkiWiki/Plugin/linkmap.pm +++ b/IkiWiki/Plugin/linkmap.pm @@ -96,7 +96,7 @@ sub genmap ($) { #{{{ waitpid $pid, 0; $SIG{PIPE}="DEFAULT"; if ($sigpipe) { - return "[[linkmap failed to run dot]]"; + return "[[".gettext("linkmap failed to run dot")."]]"; } return $ret; diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm index 625f77f21..c087f2b41 100644 --- a/IkiWiki/Plugin/mdwn.pm +++ b/IkiWiki/Plugin/mdwn.pm @@ -34,7 +34,7 @@ sub htmlize (@) { #{{{ } else { do "/usr/bin/markdown" || - error("failed to load Markdown.pm perl module ($@) or /usr/bin/markdown ($!)"); + error(sprintf(gettext("failed to load Markdown.pm perl module (%s) or /usr/bin/markdown (%s)"), $@, $!)); $markdown_sub=\&Markdown::Markdown; } } diff --git a/IkiWiki/Plugin/mirrorlist.pm b/IkiWiki/Plugin/mirrorlist.pm index 104587f3a..216d870fd 100644 --- a/IkiWiki/Plugin/mirrorlist.pm +++ b/IkiWiki/Plugin/mirrorlist.pm @@ -19,8 +19,8 @@ sub pagetemplate (@) { #{{{ sub mirrorlist ($) { #{{{ my $page=shift; - return "

Mirror". - (keys %{$config{mirrorlist}} > 1 ? "s" : ""). + return "

". + (keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")). ": ". join(", ", map { diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index 75f13f878..f43c4db7f 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -33,8 +33,8 @@ sub formbuilder_setup (@) { #{{{ label => "OpenID", size => 30, comment => '('. - htmllink("", "", "OpenID", 1, 0, "What's this?") - .($config{openidsignup} ? " | Get an OpenID" : "") + htmllink("", "", "OpenID", 1, 0, gettext("What's this?")) + .($config{openidsignup} ? " | ".gettext("Get an OpenID")."" : "") .')' ); diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index 3a8a7954f..6ba37615e 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -38,7 +38,7 @@ sub preprocess (@) { #{{{ push @orphans, $page; } - return "All pages are linked to by other pages." unless @orphans; + return gettext("All pages are linked to by other pages.") unless @orphans; return "

\n"; } # }}} diff --git a/IkiWiki/Plugin/passwordauth.pm b/IkiWiki/Plugin/passwordauth.pm index 1aac17a9e..7ffc12080 100644 --- a/IkiWiki/Plugin/passwordauth.pm +++ b/IkiWiki/Plugin/passwordauth.pm @@ -101,7 +101,7 @@ sub formbuilder_setup (@) { #{{{ } else { # First time settings. - $form->field(name => "name", comment => "(use FirstnameLastName)"); + $form->field(name => "name", comment => gettext("(use FirstnameLastName)")); if ($session->param("name")) { $form->field(name => "name", value => $session->param("name")); } @@ -141,10 +141,10 @@ sub formbuilder (@) { #{{{ 'regdate' => time})) { $form->field(name => "confirm_password", type => "hidden"); $form->field(name => "email", type => "hidden"); - $form->text("Account creation successful. Now you can Login."); + $form->text(gettext("Account creation successful. Now you can Login.")); } else { - error("Error creating account."); + error(gettext("Error creating account.")); } } elsif ($form->submitted eq 'Mail Password') { @@ -165,9 +165,9 @@ sub formbuilder (@) { #{{{ From => "$config{wikiname} admin <$config{adminemail}>", Subject => "$config{wikiname} information", Message => $template->output, - ) or error("Failed to send mail"); + ) or error(gettext("Failed to send mail")); - $form->text("Your password has been emailed to you."); + $form->text(gettext("Your password has been emailed to you.")); $form->field(name => "name", required => 0); push @$buttons, "Mail Password"; } diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm index c040deb76..a3321a32e 100644 --- a/IkiWiki/Plugin/poll.pm +++ b/IkiWiki/Plugin/poll.pm @@ -61,7 +61,7 @@ sub preprocess (@) { #{{{ $ret.="\n"; $ret.="\n"; $ret.="\n"; - $ret.="\n"; + $ret.="\n"; } $ret.="

\n
\n"; if ($open && exists $config{cgiurl}) { @@ -69,7 +69,7 @@ sub preprocess (@) { #{{{ } } if ($showtotal) { - $ret.="Total votes: $total\n"; + $ret.="".gettext("Total votes:")." $total\n"; } return "
$ret
"; } # }}} diff --git a/IkiWiki/Plugin/polygen.pm b/IkiWiki/Plugin/polygen.pm index 966b6cb51..63f6bf5db 100644 --- a/IkiWiki/Plugin/polygen.pm +++ b/IkiWiki/Plugin/polygen.pm @@ -29,7 +29,7 @@ sub preprocess (@) { #{{{ my $grmfile = '/usr/share/polygen/ita/polygen.grm'; if (! -d '/usr/share/polygen') { - return "[[polygen not installed]]"; + return "[[".gettext("polygen not installed")."]]"; } find({wanted => sub { if (substr($File::Find::name, -length($grammar)) eq $grammar) { @@ -48,10 +48,10 @@ sub preprocess (@) { #{{{ } if ($?) { - $res="[[polygen failed]]"; + $res="[[".gettext("polygen failed")."]]"; } - # Strip trainling spaces and newlines so that we flow well with the + # Strip trailing spaces and newlines so that we flow well with the # markdown text $res =~ s/\s*$//; return $res; diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 942b94986..1b5c66716 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -31,7 +31,7 @@ sub getopt () { #{{{ sub checkconfig () { #{{{ foreach my $required (qw(url cgiurl)) { if (! length $config{$required}) { - error("Must specify $required when using the search plugin\n"); + error(sprintf(gettext("Must specify %s when using the search plugin"), $required)); } } } #}}} @@ -55,13 +55,13 @@ sub pagetemplate (@) { #{{{ } #}}} sub delete (@) { #{{{ - debug("cleaning hyperestraier search index"); + debug(gettext("cleaning hyperestraier search index")); estcmd("purge -cl"); estcfg(); } #}}} sub change (@) { #{{{ - debug("updating hyperestraier search index"); + debug(gettext("updating hyperestraier search index")); estcmd("gather -cm -bc -cl -sd", map { Encode::encode_utf8($config{destdir}."/".$_) diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm index e4a9ab1a6..9479306a8 100644 --- a/IkiWiki/Plugin/shortcut.pm +++ b/IkiWiki/Plugin/shortcut.pm @@ -21,13 +21,13 @@ sub preprocess_shortcut (@) { #{{{ my %params=@_; if (! defined $params{name} || ! defined $params{url}) { - return "[[shortcut missing name or url parameter]]"; + return "[[".gettext("shortcut missing name or url parameter")."]]"; } hook(type => "preprocess", no_override => 1, id => $params{name}, call => sub { shortcut_expand($params{url}, $params{desc}, @_) }); - return "shortcut $params{name} points to $params{url}"; + return sprintf(gettext("shortcut %s points to %s"), $params{name}, $params{url}); } # }}} sub shortcut_expand ($$@) { #{{{ diff --git a/IkiWiki/Plugin/smiley.pm b/IkiWiki/Plugin/smiley.pm index 0c6f5d427..85a719337 100644 --- a/IkiWiki/Plugin/smiley.pm +++ b/IkiWiki/Plugin/smiley.pm @@ -19,7 +19,7 @@ sub setup () { #{{{ } if (! %smileys) { - debug("failed to parse any smileys, disabling plugin"); + debug(gettext("failed to parse any smileys, disabling plugin")); return; } diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index 095705604..23d9d65d8 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -16,17 +16,16 @@ sub preprocess (@) { #{{{ my %params=@_; if (! exists $params{id}) { - return "[[template missing id parameter]]" + return "[[".gettext("template missing id parameter")."]]"; } my $template_page="templates/$params{id}"; add_depends($params{page}, $template_page); my $template_file=$pagesources{$template_page}; - return "[[template ". - htmllink($params{page}, $params{destpage}, $template_page). - " not found]]" - unless defined $template_file; + return sprintf(gettext("template %s not found"), + htmllink($params{page}, $params{destpage}, $template_page)) + unless defined $template_file; my $template; eval { @@ -43,7 +42,7 @@ sub preprocess (@) { #{{{ ); }; if ($@) { - return "[[template failed to process: $@]]"; + return "[[".gettext("template failed to process:")." $@]]"; } foreach my $param (keys %params) { -- cgit v1.2.3