Coder Social home page Coder Social logo

formatnum's People

Contributors

daschtour avatar reedy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

reedy

formatnum's Issues

instead of all these parameters

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:

  • the group separator ('n' for NBSP, 't' for THINSP but better with NNBSP) to replace the ',' in number formats
  • the decimals separator to replace the '.' in number formats
  • the character to use for minus
  • the character to use for plus
  • the set of decimal digits (specified by the Unicode character for zero) : needed for Indic scripts
  • the grouping format (in most languages: every 3 digits in the integer part i.e. with the number "#,###")
  • the minimum number of digits in the integer part before using group separators (otherwise use the number format "#"); for example 4 (useful for year numbers)
  • possibly some leading and trailing prefixes for marking numbers (some languages or scripts need it because they don't have digits but reuse letters; this includes the Braille script in all languages such as "en-Brai" for English written in the Braille script)
  • possibly a way to specify formating for exponential notations: the default is 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

Default should follow interface language

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

Function comments should follow phpdoc format.

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.

Allow other chars with unicode … code?

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|.|&#8239;}} is producing 12&345.

Fabian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.