daschtour / formatnum Goto Github PK
View Code? Open in Web Editor NEWHome Page: http://www.mediawiki.org/wiki/Extension:FormatNum
License: GNU General Public License v3.0
Home Page: http://www.mediawiki.org/wiki/Extension:FormatNum
License: GNU General Public License v3.0
Transfering from https://bugzilla.wikimedia.org/show_bug.cgi?id=44905 :
With the Formatnum extension installed, {{#formatnum|2}} displays a number in
the following format no matter what the wiki language is set to:
{{#formatnum:50000|2}} displays as 50.000,00
We should have {{formatnum:1000.23|lang=fr}}
to render "1 000,23" without having to specify the default separators for the language.
If "lang=
" is not specified, it should take by default the value of the UI language (as per the "?uselang=" in the query parameters, or from the user preferences, if they are set, or from the default ContentLanguage of the wiki)
So {{formatnum:1000.23}}
would be roughly equivalent to {{formatnum:1000.23|lang={{int:lang}}}}
, but without having to use the int:lang "hack" (which requires loading resources in "Mediawiki:lang/code" containing "code" for all supported languages)
The module supporting formatnum should include the resources necessary for the number formatting of all supported languages (otherwise by default, the thousand separator will be the empty string, the decimal separator will be ".", the digits will be in "0-9".
If other parameters are specified, they overide the locale number format settings for that language. So we can still write {{formatnum:1000.23|lang=fr|tsep=}} to clear the default thousand separator (non-breaking space in French).
Some minimum locale resources to include per language are:
1E2
but setting it to 1'×10<sup>'2'</sup>'
would mean render the formatted mantissa part (1
) followed by the verbatim text "×10
" and the formatted exponent part (2
) in superscript.There should also possibly exist a way to specify alternatives in some scripts (the Arabic script supports two sets of digits, the default one being language-dependant, e.g. they are different between the Arabic language and the Urdu/Farsi languages): we could use a private script code after the language code to specify these variants ("ar" or "ar-Arab" uses the Western Indo-Arabic digits, "ur" or "ur-Qare" would use Eastern Indo-Arabic digits; but we could still use "ar-Latn" or "ur-Latn" to get Latin-Arabic digits "0-9" in Arabic or Urdu languages, or "ur-Arab" to get the Western Indo-Arabic in Urdu languages); if not possible directly in the script code there should then exist some parameter to set the character to use for zero such as "zero=*", or by appending an "Unicode CLDR locale extension" to the language code. More details about these settings in the Unicode standard and in the CLDR data.
And then deprecate the ISO and DIN specific formats or support them only as custom "speedy" aliases for the previous locale settings
With the Formatnum extension installed, {{#formatnum|2}} displays a number in
the following format no matter what the wiki language is set to:
{{#formatnum:50000|2}} displays as 50.000,00
Taking a look on
http://www.mediawiki.org/wiki/Extension:NumberFormat
Add ISO and DIN
http://de.wikipedia.org/wiki/Zahlenformat
Two Wikimedia projects, sl.wikipedia and fa.wikipedia would like to use this extension.
In this context, it'd be nice if the function comments would follow phpdoc format, to ease documentation autogeneration.
Hello, on the KSP wiki this extension was installed recently, but I'm unable to use U+202F (narrow no-break space). As a big number shouldn't be separated the default shouldn't be U+2009. Now with the unicode directly entered (“ ”) this extension won't work so I'm using a workaround now:
<span style="white-space:nowrap;">{{#formatnum:12345|0|.|t}}</span>
While {{#formatnum:12345|0|.| }}
is producing 12&345
.
Fabian
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.