From 9ecbdd129376f7ec0c9e1a55239c4adb229edfb5 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Sat, 23 Sep 2023 11:15:40 -0700 Subject: [PATCH] refactor: use Intl for battery percentage Follow GNOME Shell in using `Intl.NumberFormat` for the battery percentage label. --- po/en.po | 25 ++++++++++--------------- po/fr.po | 25 ++++++++++--------------- po/gnome-shell-extension-valent.pot | 25 ++++++++++--------------- po/nl.po | 25 ++++++++++--------------- src/status.js | 5 ++++- 5 files changed, 44 insertions(+), 61 deletions(-) diff --git a/po/en.po b/po/en.po index d7b9ad2..234c8c5 100644 --- a/po/en.po +++ b/po/en.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: gnome-shell-extension-valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/gnome-shell-extension-" "valent/issues\n" -"POT-Creation-Date: 2023-06-21 09:44-0700\n" +"POT-Creation-Date: 2023-09-23 11:13-0700\n" "PO-Revision-Date: 2022-01-16 01:10-0800\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -19,48 +19,43 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. TRANSLATORS: A notification button to show the quick-reply entry -#: src/notification.js:59 +#: src/notification.js:71 msgid "Reply" msgstr "Reply" #. TRANSLATORS: A reply entry in a notification -#: src/notification.js:69 +#: src/notification.js:81 msgid "Type a message" msgstr "Type a message" -#: src/status.js:153 -#, javascript-format -msgid "%d %%" -msgstr "" - -#: src/status.js:252 src/status.js:436 +#: src/status.js:260 src/status.js:445 msgid "Devices" msgstr "Devices" -#: src/status.js:277 src/status.js:398 src/status.js:402 +#: src/status.js:285 src/status.js:405 src/status.js:409 msgid "All Devices" msgstr "All Devices" #. TRANSLATORS: This is the number of connected devices -#: src/status.js:375 +#: src/status.js:384 #, javascript-format msgid "%d Connected" msgid_plural "%d Connected" msgstr[0] "%d Connected" msgstr[1] "%d Connected" -#: src/status.js:392 +#: src/status.js:399 msgid "Valent must be installed to connect and sync devices" msgstr "" -#: src/status.js:393 +#: src/status.js:400 msgid "Help" msgstr "" -#: src/status.js:397 +#: src/status.js:404 msgid "No available or connected devices" msgstr "" -#: src/status.js:401 +#: src/status.js:408 msgid "Turn on to connect to devices" msgstr "" diff --git a/po/fr.po b/po/fr.po index dfcb8f8..5ec69e2 100644 --- a/po/fr.po +++ b/po/fr.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: gnome-shell-extension-valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/gnome-shell-extension-" "valent/issues\n" -"POT-Creation-Date: 2023-06-21 09:44-0700\n" +"POT-Creation-Date: 2023-09-23 11:13-0700\n" "PO-Revision-Date: 2023-03-04 17:43+0100\n" "Last-Translator: Valérie Roux \n" "Language-Team: French \n" @@ -21,48 +21,43 @@ msgstr "" "X-Generator: Gtranslator 42.0\n" #. TRANSLATORS: A notification button to show the quick-reply entry -#: src/notification.js:59 +#: src/notification.js:71 msgid "Reply" msgstr "Répondre" #. TRANSLATORS: A reply entry in a notification -#: src/notification.js:69 +#: src/notification.js:81 msgid "Type a message" msgstr "Entrez un message" -#: src/status.js:153 -#, javascript-format -msgid "%d %%" -msgstr "" - -#: src/status.js:252 src/status.js:436 +#: src/status.js:260 src/status.js:445 msgid "Devices" msgstr "" -#: src/status.js:277 src/status.js:398 src/status.js:402 +#: src/status.js:285 src/status.js:405 src/status.js:409 msgid "All Devices" msgstr "Tous les appareils" #. TRANSLATORS: This is the number of connected devices -#: src/status.js:375 +#: src/status.js:384 #, javascript-format msgid "%d Connected" msgid_plural "%d Connected" msgstr[0] "%d connecté" msgstr[1] "%d connectés" -#: src/status.js:392 +#: src/status.js:399 msgid "Valent must be installed to connect and sync devices" msgstr "" -#: src/status.js:393 +#: src/status.js:400 msgid "Help" msgstr "" -#: src/status.js:397 +#: src/status.js:404 msgid "No available or connected devices" msgstr "" -#: src/status.js:401 +#: src/status.js:408 msgid "Turn on to connect to devices" msgstr "" diff --git a/po/gnome-shell-extension-valent.pot b/po/gnome-shell-extension-valent.pot index b92999e..89d27ed 100644 --- a/po/gnome-shell-extension-valent.pot +++ b/po/gnome-shell-extension-valent.pot @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: gnome-shell-extension-valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/gnome-shell-extension-" "valent/issues\n" -"POT-Creation-Date: 2023-06-21 09:44-0700\n" +"POT-Creation-Date: 2023-09-23 11:13-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -20,48 +20,43 @@ msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" #. TRANSLATORS: A notification button to show the quick-reply entry -#: src/notification.js:59 +#: src/notification.js:71 msgid "Reply" msgstr "" #. TRANSLATORS: A reply entry in a notification -#: src/notification.js:69 +#: src/notification.js:81 msgid "Type a message" msgstr "" -#: src/status.js:153 -#, javascript-format -msgid "%d %%" -msgstr "" - -#: src/status.js:252 src/status.js:436 +#: src/status.js:260 src/status.js:445 msgid "Devices" msgstr "" -#: src/status.js:277 src/status.js:398 src/status.js:402 +#: src/status.js:285 src/status.js:405 src/status.js:409 msgid "All Devices" msgstr "" #. TRANSLATORS: This is the number of connected devices -#: src/status.js:375 +#: src/status.js:384 #, javascript-format msgid "%d Connected" msgid_plural "%d Connected" msgstr[0] "" msgstr[1] "" -#: src/status.js:392 +#: src/status.js:399 msgid "Valent must be installed to connect and sync devices" msgstr "" -#: src/status.js:393 +#: src/status.js:400 msgid "Help" msgstr "" -#: src/status.js:397 +#: src/status.js:404 msgid "No available or connected devices" msgstr "" -#: src/status.js:401 +#: src/status.js:408 msgid "Turn on to connect to devices" msgstr "" diff --git a/po/nl.po b/po/nl.po index d788766..e315183 100644 --- a/po/nl.po +++ b/po/nl.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: gnome-shell-extension-valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/gnome-shell-extension-" "valent/issues\n" -"POT-Creation-Date: 2023-06-21 09:44-0700\n" +"POT-Creation-Date: 2023-09-23 11:13-0700\n" "PO-Revision-Date: 2022-09-12 20:01+0200\n" "Last-Translator: Heimen Stoffels \n" "Language-Team: Dutch\n" @@ -19,48 +19,43 @@ msgstr "" "X-Generator: Lokalize 22.08.1\n" #. TRANSLATORS: A notification button to show the quick-reply entry -#: src/notification.js:59 +#: src/notification.js:71 msgid "Reply" msgstr "Beantwoorden" #. TRANSLATORS: A reply entry in a notification -#: src/notification.js:69 +#: src/notification.js:81 msgid "Type a message" msgstr "Voer een bericht in…" -#: src/status.js:153 -#, javascript-format -msgid "%d %%" -msgstr "" - -#: src/status.js:252 src/status.js:436 +#: src/status.js:260 src/status.js:445 msgid "Devices" msgstr "" -#: src/status.js:277 src/status.js:398 src/status.js:402 +#: src/status.js:285 src/status.js:405 src/status.js:409 msgid "All Devices" msgstr "Alle apparaten" #. TRANSLATORS: This is the number of connected devices -#: src/status.js:375 +#: src/status.js:384 #, javascript-format msgid "%d Connected" msgid_plural "%d Connected" msgstr[0] "%d verbonden apparaat" msgstr[1] "%d verbonden apparaten" -#: src/status.js:392 +#: src/status.js:399 msgid "Valent must be installed to connect and sync devices" msgstr "" -#: src/status.js:393 +#: src/status.js:400 msgid "Help" msgstr "" -#: src/status.js:397 +#: src/status.js:404 msgid "No available or connected devices" msgstr "" -#: src/status.js:401 +#: src/status.js:408 msgid "Turn on to connect to devices" msgstr "" diff --git a/src/status.js b/src/status.js index 19c6cad..aff643a 100644 --- a/src/status.js +++ b/src/status.js @@ -159,7 +159,10 @@ class DeviceBattery extends St.BoxLayout { use_default_fallbacks: false, }); this._icon.fallback_icon_name = iconFallback; - this._label.text = isPresent ? _('%d\u2009%%').format(percentage) : ''; + + const formatter = new Intl.NumberFormat(undefined, {style: 'percent'}); + this._label.text = formatter.format(percentage / 100); + this.visible = isPresent; }