<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://compusofia.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFormatnum%2Fdoc</id>
	<title>Module:Formatnum/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://compusofia.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AFormatnum%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Module:Formatnum/doc&amp;action=history"/>
	<updated>2026-04-19T04:44:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://compusofia.com/w/index.php?title=Module:Formatnum/doc&amp;diff=2748&amp;oldid=prev</id>
		<title>Majestix: 1 revision imported: Initial Setup</title>
		<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Module:Formatnum/doc&amp;diff=2748&amp;oldid=prev"/>
		<updated>2026-04-12T07:44:02Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported: Initial Setup&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:44, 12 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikiNonStop:diff:1.41:old-2747:rev-2748 --&gt;
&lt;/table&gt;</summary>
		<author><name>Majestix</name></author>
	</entry>
	<entry>
		<id>https://compusofia.com/w/index.php?title=Module:Formatnum/doc&amp;diff=2747&amp;oldid=prev</id>
		<title>en&gt;Mr Pie 5: Removed Template:Protected, as that template has been deleted.</title>
		<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Module:Formatnum/doc&amp;diff=2747&amp;oldid=prev"/>
		<updated>2024-01-29T20:01:03Z</updated>

		<summary type="html">&lt;p&gt;Removed Template:Protected, as that template has been deleted.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating|release}}{{Module rating|protected}}&lt;br /&gt;
This module formats a number in the local format, based on MediaWiki data. This module is used by [[Template:Formatnum]]. For usage instructions, please take a look at [[Template:Formatnum]].&lt;br /&gt;
&lt;br /&gt;
Current limitations:&lt;br /&gt;
* Numbers with more than 14 decimals are not supported.&lt;br /&gt;
* It still does not allow more than 20 different &amp;quot;KnownLanguages&amp;quot; (in MediaWiki&amp;#039;s core library for Lua) on one page. This means that you can have at a maximum 20 module transclusions, where each of them is formatting a number into a different language.&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
* Improve these limits by not using mw.formatNum() — and fix the various bugs in that MediaWiki module (including missing or incorrect data for some languages).&lt;br /&gt;
** See [https://phabricator.wikimedia.org/diffusion/ELUA/browse/master/engines/LuaCommon/LanguageLibrary.php /engines/LuaCommon/LanguageLibrary.php] in Scribunto PHP library implementing the MediaWiki module.&lt;br /&gt;
** See [https://phabricator.wikimedia.org/diffusion/MW/browse/master/languages/Language.php /languages/Language.php] in MediaWiki core library with the default support code for all known languages&lt;br /&gt;
** See [https://phabricator.wikimedia.org/diffusion/MW/browse/master/languages/classes /languages/classes/Language*.php] in MediaWiki core library for replacement code specific to some languages&lt;br /&gt;
** See [https://phabricator.wikimedia.org/daiffusion/MW/browse/master/resources/src/mediawiki.language/mediawiki.language.numbers.js /resources/src/mediawiki.language/mediawiki.language.numbers.js] for similar function in MediaWiki client-side JavaScript library&lt;br /&gt;
* Support more languages and localized digits (we need more complete mappings of languages to their numeric scripts for digits, more data for localized separators and the number of digits in groups).&lt;br /&gt;
* Properly handle rounding of the least significant figure when there are decimals in excess for the specified precision, instead of truncating them.&lt;br /&gt;
* Reference data:&lt;br /&gt;
** See [http://www.unicode.org/cldr/charts/27/by_type/core_data.numbering_systems.html By-Type Chart: Core Data: Numbering Systems] in Unicode CLDR data (mappings of languages to numbering systems)&lt;br /&gt;
*** [http://unicode.org/cldr/trac/browser/trunk/common/supplemental/numberingSystems.xml /common/supplemental/numberingSystems.xml] in Unicode CLDR data (digits and algorithms for each numbering system)&lt;br /&gt;
*** [http://www.unicode.org/reports/tr35/tr35-numbers.html#Rule-Based_Number_Formatting Rule-Based Number Formatting] in Unicode TR35: LDML (Locale Data Markup Language)&lt;br /&gt;
*** [http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#details icu::RuleBasedNumberFormat Class Reference: Detailed Description] in ICU documentation, for the RBNF syntax used in CLDR data for implementing algorithmic number systems.&lt;br /&gt;
** See [http://www.unicode.org/cldr/charts/27/by_type/numbers.symbols.html By-Type Chart: Numbers: Symbols] in Unicode CLDR data (separators, signs, etc.)&lt;br /&gt;
** See [http://www.unicode.org/cldr/charts/27/by_type/numbers.number_formatting_patterns.html By-Type Chart: Core Data: Number Formatting Patterns] in Unicode CLDR data (formatting numbers using those numbering systems)&lt;br /&gt;
*** [http://www.unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns Number Format Patterns] in Unicode TR35: LDML (Locale Data Markup Language)&lt;br /&gt;
&lt;br /&gt;
=== Using this module from templates ===&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;formatnum|1=&amp;#039;&amp;#039;value&amp;#039;&amp;#039;|2=&amp;#039;&amp;#039;lang&amp;#039;&amp;#039;|prec=&amp;#039;&amp;#039;prec&amp;#039;&amp;#039;|sep=&amp;#039;&amp;#039;compact&amp;#039;&amp;#039;&amp;lt;nowiki&amp;gt;}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;lang&amp;#039;&amp;#039;&amp;#039; — language code as a string (e.g. &amp;#039;en&amp;#039;, &amp;#039;de&amp;#039;, etc.). If the language is not specified (nil or empty string) or not supported, the current user&amp;#039;s language (as reported by MediaWiki&amp;#039;s &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{int:Lang}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;) will be used.&lt;br /&gt;
: The &amp;#039;&amp;#039;&amp;#039;lang&amp;#039;&amp;#039;&amp;#039; named parameter is also a supported alias of the 2nd parameter.&lt;br /&gt;
: The value &amp;quot;arabic-indic&amp;quot; is also currently supported as an alias, and replaced by a supported language code.&lt;br /&gt;
* See formatNum() below for the expected values and the description of other parameter values.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
: This template internally uses &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;#invoke:Formatnum|main}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; to pass indirectly its parameters to the main() function of this module in the parent frame.&lt;br /&gt;
&lt;br /&gt;
=== formatNum() ===&lt;br /&gt;
&lt;br /&gt;
This function converts an value into a localized number.&lt;br /&gt;
&lt;br /&gt;
Unlike &amp;quot;Language:formatNum()&amp;quot; in MediaWiki&amp;#039;s core libraries for Lua, it correctly supports numbers using exponential notations such as 1e15 (MediaWiki&amp;#039;s core function is currently broken and randomly forgets the exponent for some language, so that its formated numbers are incorrectly scaled and display wrong values).&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(value, lang, prec, compact)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;#039; — as an ASCII-only number or string. If the string cannot be converted to a number with Lua&amp;#039;s tonumber(), that string will be returned as is.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;lang&amp;#039;&amp;#039;&amp;#039; — language code as a string (e.g. &amp;#039;en&amp;#039;, &amp;#039;de&amp;#039;, etc.). If that language is not supported, localized digits and separators will not be used (except for a few languages)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;prec&amp;#039;&amp;#039;&amp;#039; — if not nil and not negative, this is the number of digits in displayed decimals (by truncating the decimals in excess or by adding zeroes). Valid range: 0 to 14.&lt;br /&gt;
** when prec is not specified or nil, the decimal separator is shown only if there are 1 or more visible decimals;&lt;br /&gt;
** when prec is negative or non integer it is treated like nil;&lt;br /&gt;
** when prec is 0, there will never be any decimal separator or any displayed decimals;&lt;br /&gt;
** when prec is positive, a decimal separator will always be present before this number of decimals, but when prec is higher than 14, it is treated like 14.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;compact&amp;#039;&amp;#039;&amp;#039; — if this option is not nil and not false, don&amp;#039;t return any localized grouping separators (the localized decimal separator and digits are still used).&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345.123)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — convert to user&amp;#039;s language, using localized digits and separators&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345.123,&amp;#039;&amp;#039;)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — same thing (language code not supported)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345.123,&amp;#039;default&amp;#039;)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — same thing (language code not supported)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345.123,&amp;#039;en&amp;#039;)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — convert to English: &amp;quot;12,345.123&amp;quot;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345.123,&amp;#039;fr&amp;#039;)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — convert to French: &amp;quot;12&amp;amp;nbsp;345,123&amp;quot;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345.123,&amp;#039;fr&amp;#039;,2)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — same thing but limit to 2 decimals: &amp;quot;12&amp;amp;nbsp;345,12&amp;quot;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345,&amp;#039;fr&amp;#039;,2)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — same thing (2 null decimals are padded): &amp;quot;12&amp;amp;nbsp;345,00&amp;quot;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;formatted_string = formatnum.formatNum(12345,&amp;#039;fr&amp;#039;,2,true)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; — same thing but without grouping separators: &amp;quot;12345,00&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Limitations:&lt;br /&gt;
* Same limit of 20 &amp;quot;KnownLanguages&amp;quot; (because it still depends on mw.Language module in order to detect localized digits and separators).&lt;br /&gt;
* When specifying the &amp;quot;prec&amp;quot; parameter, decimals in excess are just truncated, and the least significant digit is not rounded.&lt;/div&gt;</summary>
		<author><name>en&gt;Mr Pie 5</name></author>
	</entry>
</feed>