mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
After 6fcef30cc50, group separators were always included in the results from format_number (even if a locale which doesn't use them like the 'C' locale is specified). 6fcef30cc50 was added to fix an old regression, but in doing so we lost flexibility to skip unwanted separators. Workaround this by introducing a new opt-in omit_group_separators argument for format_number to skip the thousand separators when desired. Also add an opt-in trim_trailing_zeroes argument for further flexibility.
38 lines
1.6 KiB
Plaintext
38 lines
1.6 KiB
Plaintext
{
|
|
"name": "format_number",
|
|
"type": "function",
|
|
"groups": ["String"],
|
|
"description": "Returns a number formatted with the locale separator for thousands. By default the current QGIS user locale is used. Also truncates the decimal places to the number of supplied places.",
|
|
"arguments": [{
|
|
"arg": "number",
|
|
"description": "number to be formatted"
|
|
}, {
|
|
"arg": "places",
|
|
"optional": true,
|
|
"default": "0",
|
|
"description": "integer representing the number of decimal places to truncate the string to."
|
|
}, {
|
|
"arg": "language",
|
|
"optional": true,
|
|
"description": "language (lowercase, two- or three-letter, <a href='https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes'>ISO 639 language code</a>) used to format the number into a string. By default the current QGIS user locale is used."
|
|
}, {
|
|
"arg": "omit_group_separators",
|
|
"optional": true,
|
|
"default": "false",
|
|
"description": "if set to true then group separators will not be included in the string"
|
|
}, {
|
|
"arg": "trim_trailing_zeroes",
|
|
"optional": true,
|
|
"default": "false",
|
|
"description": "if set to true then trailing zeros following the decimal point will be trimmed from the string"
|
|
}],
|
|
"examples": [{
|
|
"expression": "format_number(10000000.332,2)",
|
|
"returns": "'10,000,000.33' if e.g. the current locale is an English variant"
|
|
}, {
|
|
"expression": "format_number(10000000.332,2,'fr')",
|
|
"returns": "'10 000 000,33'"
|
|
}],
|
|
"tags": ["formatted", "truncates", "places", "separator", "decimal", "default", "thousands", "locale", "language"]
|
|
}
|