From 928f721880b56bb666d7464bfb80cc7d8455eff2 Mon Sep 17 00:00:00 2001 From: J-D <16978110+createthisnl@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:41:24 +0100 Subject: [PATCH] Update config_flow.py to work better with translations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed device_count and scanner_count strings. The variables from these strings have been split into separate keys: device_counter_active, device_counter_devices, scanner_counter_active, scanner_counter_scanners. These keys only contain the numerical values ​​and are applied as such in the translation file. I also tried to move the status messages to the translation file, but I haven't succeeded yet. The preparations for this are already in the .json translation files. --- custom_components/bermuda/config_flow.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/bermuda/config_flow.py b/custom_components/bermuda/config_flow.py index e76d90e..62a9c44 100644 --- a/custom_components/bermuda/config_flow.py +++ b/custom_components/bermuda/config_flow.py @@ -142,8 +142,11 @@ async def async_step_init(self, user_input=None): # pylint: disable=unused-argu active_devices = self.coordinator.count_active_devices() active_scanners = self.coordinator.count_active_scanners() - messages["device_count"] = f"{active_devices} active out of {len(self.devices)}" - messages["scanner_count"] = f"{active_scanners} active out of {len(self.coordinator.scanner_list)}" + messages["device_counter_active"] = f"{active_devices}" + messages["device_counter_devices"] = f"{len(self.devices)}" + messages["scanner_counter_active"] = f"{active_scanners}" + messages["scanner_counter_scanners"] = f"{len(self.coordinator.scanner_list)}" + if len(self.coordinator.scanner_list) == 0: messages["status"] = ( "You need to configure some bluetooth scanners before Bermuda will have anything to work with. " @@ -159,7 +162,7 @@ async def async_step_init(self, user_input=None): # pylint: disable=unused-argu messages["status"] = "You have at least some active devices, this is good." # Build a markdown table of scanners so the user can see what's up. - scanner_table = "\nStatus of scanners:\n\n|Scanner|Address|Last advertisement|\n|---|---|---:|\n" + scanner_table = "\n\nStatus of scanners:\n\n|Scanner|Address|Last advertisement|\n|---|---|---:|\n" # Use emoji to indicate if age is "good" for scanner in self.coordinator.get_active_scanner_summary(): age = int(scanner.get("last_stamp_age", 999))