From 6f7f0f369b5e6da3f4615e07d69832afeffd0a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 21 Sep 2023 20:55:31 +0200 Subject: [PATCH] status/system: Use Intl to format battery percentage The exact way of formatting a percentage value is locale specific: https://en.wikipedia.org/wiki/Percent_sign#Correct_style. We account for that by marking the string for translations, but then get it wrong for the default US locale (go us!). But given that the javascript engine itself provides us with a way of formatting a percentage in a locale-specific way, that seems the better option than putting the burden on our own developers and translators. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7005 Part-of: --- js/ui/status/system.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/ui/status/system.js b/js/ui/status/system.js index 8680b0bdd..ff9fa5624 100644 --- a/js/ui/status/system.js +++ b/js/ui/status/system.js @@ -93,8 +93,9 @@ const PowerToggle = GObject.registerClass({ use_default_fallbacks: false, }); + const formatter = new Intl.NumberFormat(undefined, {style: 'percent'}); this.set({ - title: _('%d\u2009%%').format(this._proxy.Percentage), + title: formatter.format(this._proxy.Percentage / 100), fallback_icon_name: this._proxy.IconName, gicon, });