Warning: You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more.
Log in or
create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision |
Your text |
| Line 58: |
Line 58: |
| | [[Special:Diff/6419|100th edit.]] (Undoing my own edit) | | | [[Special:Diff/6419|100th edit.]] (Undoing my own edit) |
| |} | | |} |
|
| |
| == Number formatting for thousands separator ==
| |
| In general Lua, text formatting can be done with:
| |
| <syntaxhighlight lang="lua" line>
| |
| function Format(amount)
| |
| local formatted = amount
| |
| while true do
| |
| formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
| |
| if (k == 0) then
| |
| break
| |
| end
| |
| end
| |
| return formatted
| |
| end
| |
| </syntaxhighlight>
| |
|
| |
| On Mediawiki installations, formatting should instead be done by:
| |
| <syntaxhighlight lang="lua" line>
| |
| local lang = mw.language.getContentLanguage()
| |
| local function Format(amount)
| |
| local formatted = amount
| |
| if(type(formatted) ~= "number") then return "<span style=\"color:red;\">Cannot format non-number value.</span>" end
| |
| return lang:formatNum(tonumber(formatted))
| |
| end
| |
| </syntaxhighlight>
| |