+
+### islanguagecode
+ok(IkiWiki::Plugin::po::islanguagecode('en'));
+ok(IkiWiki::Plugin::po::islanguagecode('es'));
+ok(IkiWiki::Plugin::po::islanguagecode('arn'));
+ok(! IkiWiki::Plugin::po::islanguagecode('es_'));
+ok(! IkiWiki::Plugin::po::islanguagecode('_en'));
+
+# Actually render translated pages
+use IkiWiki::Render;
+
+my %output;
+foreach my $page (sort keys %pagesources) {
+ my $source = "$config{srcdir}/$pagesources{$page}";
+ if (-e $source) {
+ IkiWiki::scan($pagesources{$page});
+ }
+}
+
+# This is the most complicated case, so use this while we test rendering
+$config{po_link_to}='current';
+
+foreach my $page (sort keys %pagesources) {
+ my $source = "$config{srcdir}/$pagesources{$page}";
+ if (-e $source && defined IkiWiki::pagetype($pagesources{$page})) {
+ IkiWiki::scan($pagesources{$page});
+ my $content = readfile($source);
+ #print STDERR "-------------------------------------\n";
+ #print STDERR "SOURCE: $page: $content\n";
+ $content = IkiWiki::filter($page, $page, $content);
+ #print STDERR "FILTERED: $page: $content\n";
+ $content = IkiWiki::preprocess($page, $page, $content);
+ #print STDERR "PREPROCESSED: $page: $content\n";
+ $content = IkiWiki::linkify($page, $page, $content);
+ #print STDERR "LINKIFIED: $page: $content\n";
+ $content = IkiWiki::htmlize($page, $page, IkiWiki::pagetype($pagesources{$page}), $content);
+ #print STDERR "HTMLIZED: $page: $content\n";
+ IkiWiki::run_hooks(format => sub {
+ $content=shift->(
+ page => $page,
+ content => $content,
+ );
+ });
+ #print STDERR "FORMATTED: $page: $content\n";
+ $output{$page} = $content;
+ }
+}
+
+like($output{index}, qr{
+ <p>
+ <a\s+href="\./translatable/index\.en\.html">
+ translatable
+ </a>\s*
+ <a\s+href="\./nontranslatable/">
+ nontranslatable
+ </a>
+ </p>
+}sx);
+
+like($output{'index.es'}, qr{
+ <p>
+ <a\s+href="\./translatable/index\.es\.html">
+ translatable
+ </a>\s*
+ <a\s+href="\./nontranslatable/">
+ nontranslatable
+ </a>
+ </p>
+}sx);
+
+like($output{'index.fr'}, qr{
+ <p>
+ <a\s+href="\./translatable/index\.fr\.html">
+ translatable
+ </a>\s*
+ <a\s+href="\./nontranslatable/">
+ nontranslatable
+ </a>
+ </p>
+}sx);
+
+like($output{'translatable'}, qr{
+ <a\s+href="\.\./nontranslatable/">
+ nontranslatable
+ </a>
+}sx);
+
+TODO: {
+local $TODO = 'was [[/]] meant to be a link to the index?';
+unlike($output{'nontranslatable'}, qr{
+ class=.createlink.
+}sx);
+};
+like($output{'nontranslatable'}, qr{
+ <a\s+href="\.\./translatable/index\.en\.html">
+ translatable
+ </a>
+}sx);
+
+like($output{debian911356}, qr{
+ <p>Before\sfirst\sinline</p>
+ \s*
+ <p>English\scontent</p>
+ \s*
+ <p>Between\sinlines</p>
+ \s*
+ <p>English\scontent</p>
+ \s*
+ <p>After\sinlines</p>
+}sx);
+
+like($output{'debian911356.fr'}, qr{
+ <p>Avant\sla\spremière\sinline</p>
+ \s*
+ <p>Contenu\sfrançais</p>
+ \s*
+ <p>Entre\sles\sinlines</p>
+ \s*
+ <p>Contenu\sfrançais</p>
+ \s*
+ <p>Après\sles\sinlines</p>
+}sx);
+
+# Variation of Debian #911356 without using raw inlines.
+like($output{debian911356ish}, qr{
+ <p>Before\sfirst\sinline</p>
+ \s*
+ <!--feedlinks-->
+ \s*
+ <div\sclass="inlinecontent">
+ \s*
+ <h6>debian911356-inlined</h6>
+ \s*
+ <p>English\scontent</p>
+ \s*
+ </div><!--inlinecontent-->
+ \s*
+ <p>Between\sinlines</p>
+ \s*
+ <!--feedlinks-->
+ \s*
+ <div\sclass="inlinecontent">
+ \s*
+ <h6>debian911356-inlined</h6>
+ \s*
+ <p>English\scontent</p>
+ \s*
+ </div><!--inlinecontent-->
+ \s*
+ <p>After\sinlines</p>
+}sx);
+
+like($output{'debian911356ish.fr'}, qr{
+ <p>Avant\sla\spremière\sinline</p>
+ \s*
+ <!--feedlinks-->
+ \s*
+ <div\sclass="inlinecontent">
+ \s*
+ <h6>debian911356-inlined\.fr</h6>
+ \s*
+ <p>Contenu\sfrançais</p>
+ \s*
+ </div><!--inlinecontent-->
+ \s*
+ <p>Entre\sles\sinlines</p>
+ \s*
+ <!--feedlinks-->
+ \s*
+ <div\sclass="inlinecontent">
+ \s*
+ <h6>debian911356-inlined\.fr</h6>
+ \s*
+ <p>Contenu\sfrançais</p>
+ \s*
+ </div><!--inlinecontent-->
+ \s*
+ <p>Après\sles\sinlines</p>
+}sx);
+
+done_testing;