Skip to content

Commit

Permalink
fix: don't automatically set default locale (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya authored Jun 28, 2024
1 parent 7f58263 commit 6637411
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions ecowitt2mqtt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
DEFAULT_BOOLEAN_BATTERY_TRUE_VALUE,
DEFAULT_ENDPOINT,
DEFAULT_HASS_DISCOVERY_PREFIX,
DEFAULT_LOCALE,
DEFAULT_MQTT_PORT,
DEFAULT_PORT,
ENV_BATTERY_OVERRIDES,
Expand Down Expand Up @@ -252,7 +251,7 @@ def get_cli_arguments(args: list[str]) -> dict[str, Any]:
parser.add_argument(
"--locale",
dest=CONF_LOCALE,
help=f"The locale to use (default: {DEFAULT_LOCALE})",
help="The locale to set (default: system default)",
metavar=CONF_LOCALE,
)
parser.add_argument(
Expand Down
3 changes: 1 addition & 2 deletions ecowitt2mqtt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
DEFAULT_BOOLEAN_BATTERY_TRUE_VALUE,
DEFAULT_ENDPOINT,
DEFAULT_HASS_DISCOVERY_PREFIX,
DEFAULT_LOCALE,
DEFAULT_MQTT_PORT,
DEFAULT_PORT,
ENV_BATTERY_OVERRIDES,
Expand Down Expand Up @@ -170,7 +169,7 @@ class Config(BaseModel):
uuid: str = Field(default_factory=lambda: uuid4().hex)

# Misc. parameters:
locale: str = DEFAULT_LOCALE
locale: str | None = None

@model_validator(mode="before")
@classmethod
Expand Down
1 change: 0 additions & 1 deletion ecowitt2mqtt/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
DEFAULT_BOOLEAN_BATTERY_TRUE_VALUE: Final = 1
DEFAULT_ENDPOINT: Final = "/data/report"
DEFAULT_HASS_DISCOVERY_PREFIX: Final = "homeassistant"
DEFAULT_LOCALE: Final = "en_US.UTF-8"
DEFAULT_MQTT_PORT: Final = 1883
DEFAULT_PORT: Final = 8080

Expand Down
5 changes: 3 additions & 2 deletions ecowitt2mqtt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def __init__(self, params: dict[str, Any]) -> None:
LOGGER.debug("Input CLI options/environment variables: %s", params)
LOGGER.debug("Configs loaded: %s", self.configs)

LOGGER.debug("Setting locale: %s", self.configs.default_config.locale)
locale.setlocale(locale.LC_ALL, self.configs.default_config.locale)
if provided_locale := self.configs.default_config.locale:
LOGGER.debug("Setting locale: %s", self.configs.default_config.locale)
locale.setlocale(locale.LC_ALL, provided_locale)

self.runtime = Runtime(self)

Expand Down

0 comments on commit 6637411

Please sign in to comment.