Skip to content

Commit

Permalink
refactor: use Intl for battery percentage
Browse files Browse the repository at this point in the history
Follow GNOME Shell in using `Intl.NumberFormat` for the battery
percentage label.
  • Loading branch information
andyholmes committed Sep 23, 2023
1 parent e9814ff commit 9ecbdd1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 61 deletions.
25 changes: 10 additions & 15 deletions po/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ""
25 changes: 10 additions & 15 deletions po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>\n"
"Language-Team: French <[email protected]>\n"
Expand All @@ -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 ""
25 changes: 10 additions & 15 deletions po/gnome-shell-extension-valent.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -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 ""
25 changes: 10 additions & 15 deletions po/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>\n"
"Language-Team: Dutch\n"
Expand All @@ -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 ""
5 changes: 4 additions & 1 deletion src/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9ecbdd1

Please sign in to comment.