parent
8503e57916
commit
8b47046fde
199
t/po.t
199
t/po.t
|
@ -69,9 +69,13 @@ $pagesources{'translatable.fr'}='translatable.fr.po';
|
|||
$pagesources{'translatable.es'}='translatable.es.po';
|
||||
$pagesources{'nontranslatable'}='nontranslatable.mdwn';
|
||||
$pagesources{'debian911356'}='debian911356.mdwn';
|
||||
$pagesources{'debian911356ish'}='debian911356ish.mdwn';
|
||||
$pagesources{'debian911356.fr'}='debian911356.fr.po';
|
||||
$pagesources{'debian911356ish.fr'}='debian911356ish.fr.po';
|
||||
$pagesources{'debian911356-inlined'}='debian911356-inlined.mdwn';
|
||||
$pagesources{'debian911356-inlined.fr'}='debian911356-inlined.fr.po';
|
||||
$pagesources{'templates/feedlink.tmpl'}='templates/feedlink.tmpl';
|
||||
$pagesources{'templates/inlinepage.tmpl'}='templates/inlinepage.tmpl';
|
||||
my $now=time;
|
||||
foreach my $page (keys %pagesources) {
|
||||
$IkiWiki::pagecase{lc $page}=$page;
|
||||
|
@ -124,6 +128,46 @@ writefile('debian911356-inlined.fr.po', $config{srcdir}, <<EOF);
|
|||
msgid "English content"
|
||||
msgstr "Contenu français"
|
||||
EOF
|
||||
writefile('debian911356ish.mdwn', $config{srcdir}, <<EOF);
|
||||
Before first inline
|
||||
|
||||
[[!inline pages="debian911356-inlined"]]
|
||||
|
||||
Between inlines
|
||||
|
||||
[[!inline pages="debian911356-inlined"]]
|
||||
|
||||
After inlines
|
||||
EOF
|
||||
writefile('debian911356ish.fr.po', $config{srcdir}, <<EOF);
|
||||
msgid "" msgstr ""
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8bit\\n"
|
||||
|
||||
msgid "Before first inline"
|
||||
msgstr "Avant la première inline"
|
||||
|
||||
msgid "[[!inline pages=\\"debian911356-inlined\\"]]\\n"
|
||||
msgstr "[[!inline pages=\\"debian911356-inlined.fr\\"]]\\n"
|
||||
|
||||
msgid "Between inlines"
|
||||
msgstr "Entre les inlines"
|
||||
|
||||
msgid "After inlines"
|
||||
msgstr "Après les inlines"
|
||||
EOF
|
||||
# We don't actually care what the feed links look like, so skip them
|
||||
writefile('templates/feedlink.tmpl', $config{srcdir}, <<EOF);
|
||||
<!--feedlinks-->
|
||||
EOF
|
||||
# Make inlines' appearance predictable so we can screen-scrape them
|
||||
writefile('templates/inlinepage.tmpl', $config{srcdir}, <<EOF);
|
||||
<div class="inlinecontent">
|
||||
<h6><TMPL_VAR TITLE></h6>
|
||||
<TMPL_VAR CONTENT>
|
||||
</div><!--inlinecontent-->
|
||||
EOF
|
||||
|
||||
### istranslatable/istranslation
|
||||
# we run these tests twice because memoization attempts made them
|
||||
|
@ -297,12 +341,22 @@ ok(! IkiWiki::Plugin::po::islanguagecode('_en'));
|
|||
use IkiWiki::Render;
|
||||
|
||||
my %output;
|
||||
foreach my $page (keys %pagesources) {
|
||||
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 "-------------------------------------\n";
|
||||
#print STDERR "SOURCE: $page: $content\n";
|
||||
$content = IkiWiki::filter($page, $page, $content);
|
||||
#print STDERR "FILTERED: $page: $content\n";
|
||||
|
@ -311,12 +365,69 @@ foreach my $page (keys %pagesources) {
|
|||
$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";
|
||||
#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;
|
||||
ok(utf8::is_utf8($content), "htmlized content should be utf8");
|
||||
}
|
||||
}
|
||||
|
||||
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*
|
||||
|
@ -356,4 +467,84 @@ like($output{'debian911356.fr'}, qr{
|
|||
}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*
|
||||
.* # TODO: This paragraph gets mangled (Debian #911356)
|
||||
\s*
|
||||
<p>Après\sles\sinlines</p>
|
||||
}sx);
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Debian bug #911356";
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue