1 I want inject IkiWiki::showform and use replace submit button with translated button,
2 but it seem no effect in cgi, does IkiWiki::showfrom can not be injectd when run as cgi?
4 by the way, what about add a post-showform hook to ikiwiki?
9 package IkiWiki::Plugin::chinesize;
15 inject(name => 'IkiWiki::showform', call => \&myshowform);
17 sub myshowform ($$$$;@) {
18 my $form=prepform(@_);
24 my $str=cgitemplate($cgi, $form->title,
25 $form->render(submit => $buttons), @_);
27 my %names = ("Save Page" => "保存页面",
41 "Save Preferences" => "保存选项",
42 "Confirm Password" => "再次输入密码",
43 "Create Account" => "创建帐户",
44 "Reset Password" => "重置密码",
45 "Insert Links" => "插入链接",
46 "Rename Attachment" => "重命名附件",
47 "Remove Attachments" => "删除附件",
48 "FormattingHelp" => "格式帮助",
50 "Save Setup" => "保存设置",
51 "Advanced Mode" => "高级模式",
52 "Account Creation Password" => "请输入帐户创建密码(管理员预设)"
55 foreach my $old_name (keys(%names))
57 my $new_name = Encode::decode_utf8($names{$old_name});
58 $str =~ s/<input +id="([_A-Za-z0-9]+)" +name="([_A-Za-z0-9]+)" +type="([_A-Za-z0-9]+)" +value="($old_name)" +\/>/<button id="$1" name="$2" type="$3" value="$4">$new_name<\/button>/g;
59 $str =~ s/<input +name="([_A-Za-z0-9]+)" +type="([_A-Za-z0-9]+)" +value="($old_name)" +\/>/<button name="$1" type="$2" value="$3">$new_name<\/button>/g;
60 $str =~ s/<input +class="([_A-Za-z0-9]+)" +id="([_A-Za-z0-9]+)" +name="([_A-Za-z0-9]+)" +type="([_A-Za-z0-9]+)" +value="($old_name)" +\/>/<button class="$1" id="$2" name="$3" type="$4" value="$5">$new_name<\/button>/g;
61 $str =~ s/<div class="([_A-Za-z0-9]+)" id="([_A-Za-z0-9]+)">$old_name<\/div>/<div class="$1" id="$2">$new_name<\/div>/g;
62 $str =~ s/<div class="([_A-Za-z0-9]+)" id="([_A-Za-z0-9]+)"><span class="([_A-Za-z0-9]+)">$old_name<\/span><\/div>/<div class="$1" id="$2"><span class="$3">$new_name<\/span><\/div>/g;
63 $str =~ s/<a href="\.\/ikiwiki\/formatting\/">($old_name)<\/a>/<a href="\.\/ikiwiki\/formatting\/">$new_name<\/a>/g;
66 printheader($session);