Stop formatting "1.2" as "1,2" in languages like German

The new extends="…" feature is using numbers like "1.2". These should be
localized in languages like Hebrew that uses other symbols for the digits.
But the "." should not change.

The existing feature when a <ref> is reused multiple times does have the
same "issue". But it seems this is intentional, because it is covered by
a test. Note this is not visible in German, because German uses custom
labels "a", "b", and so on.

This patch also improves the so called "smoke" tests and makes one cover
numbers up to "1,10" for a <ref> that is reused that often.

Bug: T239725
Change-Id: Iffcb56e1c7be09cefed9dabb1d6391eb6ad995ce
This commit is contained in:
Thiemo Kreuz 2019-12-04 09:10:03 +01:00
parent d40bf92396
commit 54333c9bd6
4 changed files with 30 additions and 6 deletions

View file

@ -235,11 +235,13 @@ class FootnoteBodyFormatter {
int $offset,
int $max
) : string {
$scope = strlen( $max );
$ret = MediaWikiServices::getInstance()->getContentLanguage()->formatNum(
$base . '.' . sprintf( "%0{$scope}s", $offset )
$language = MediaWikiServices::getInstance()->getContentLanguage();
return $language->formatNum(
$base .
'.' .
str_pad( $offset, strlen( $max ), '0', STR_PAD_LEFT )
);
return $ret;
}
/**

View file

@ -67,7 +67,7 @@ class FootnoteMarkFormatter {
}
}
if ( isset( $ref['extendsIndex'] ) ) {
$label .= $language->formatNum( '.' . $ref['extendsIndex'] );
$label .= '.' . $language->formatNum( $ref['extendsIndex'], true );
}
$key = $ref['name'] ?? $ref['key'];

View file

@ -35,6 +35,8 @@ wgCiteBookReferencing=true
!! test
T236256 - Extending the same base multiple times is fine
!! options
language=de
!! config
wgCiteBookReferencing=true
!! wikitext

View file

@ -36,16 +36,36 @@ Smoke test for duplicated references with conflicting text
!! test
Smoke test for references that are reused *before* defined in the text
!! options
language=de
!! wikitext
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a" />
<ref name="a">text</ref>
<ref name="b">other</ref>
!! html
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-1" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-2" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-3" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-4" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-5" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-6" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-7" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-8" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-9" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-a_1-10" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
</p>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a_1-0">1.0</a></sup> <sup><a href="#cite_ref-a_1-1">1.1</a></sup></span> <span class="reference-text">text</span>
<li id="cite_note-a-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a_1-0">1,00</a></sup> <sup><a href="#cite_ref-a_1-1">1,01</a></sup> <sup><a href="#cite_ref-a_1-2">1,02</a></sup> <sup><a href="#cite_ref-a_1-3">1,03</a></sup> <sup><a href="#cite_ref-a_1-4">1,04</a></sup> <sup><a href="#cite_ref-a_1-5">1,05</a></sup> <sup><a href="#cite_ref-a_1-6">1,06</a></sup> <sup><a href="#cite_ref-a_1-7">1,07</a></sup> <sup><a href="#cite_ref-a_1-8">1,08</a></sup> <sup><a href="#cite_ref-a_1-9">1,09</a></sup> <sup><a href="#cite_ref-a_1-10">1,10</a></sup></span> <span class="reference-text">text</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">other</span>
</li>