Skip to content

Commit

Permalink
feat(core): add config to use numberformatter without disabling sites…
Browse files Browse the repository at this point in the history
…tats

Add the ability to disable numberformatter independently from sitestats
Due to an upstream issue, numberforrmatter can throw an exception in some
instances (#474). This will help to mitigate the issue.
  • Loading branch information
alistair3149 committed Jun 14, 2022
1 parent 4f64564 commit 00e1f57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Name | Description | Values | Default
`$wgCitizenShowPageTools` | The condition of page tools visibility | `true` - always visible; `login` - visible to logged-in users; `permission` - visible to users with the right permissions | `true`
`$wgCitizenSiteToolsPortlet` | ID of the portlet to attach the site tools | string |
`$wgCitizenEnableDrawerSiteStats` | Enables the site statistics in drawer menu | `true` - enable; `false` - disable | `true`
`$wgCitizenUseNumberFormatter` | Use NumberFormatter for site statistics, which allows formatting number in a localized way | `true` - enable; `false` - disable | `true`
`$wgCitizenThemeColor` | The color defined in the `theme-color` meta tag | Hex color code | `#131a21`

### Search suggestions
Expand Down
2 changes: 1 addition & 1 deletion includes/Partials/Drawer.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private function getSiteStatsData(): array {
$fmt = null;

// Get NumberFormatter here so that we don't have to call it for every stats
if ( class_exists( \NumberFormatter::class ) ) {
if ( $this->getConfigValue( 'CitizenUseNumberFormatter' ) && class_exists( \NumberFormatter::class ) ) {
$locale = $skin->getLanguage()->getHtmlCode() ?? 'en_US';
$fmt = new \NumberFormatter( $locale, \NumberFormatter::PADDING_POSITION );
$fmt->setAttribute( \NumberFormatter::ROUNDING_MODE, \NumberFormatter::ROUND_DOWN );
Expand Down
6 changes: 6 additions & 0 deletions skin.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,12 @@
"description": "Enables the site statistics in drawer menu",
"descriptionmsg": "citizen-config-enabledrawersitestats",
"public": true
},
"UseNumberFormatter": {
"value": true,
"description": "Use NumberFormatter for site statistics",
"descriptionmsg": "citizen-config-usenumberformatter",
"public": true
}
},
"manifest_version": 2
Expand Down

0 comments on commit 00e1f57

Please sign in to comment.