Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/pendulum/locales/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pathlib import Path
from typing import Any
from typing import ClassVar
from typing import Dict
from typing import cast


Expand All @@ -23,12 +22,15 @@ def __init__(self, locale: str, data: Any) -> None:

@classmethod
def load(cls, locale: str | Locale) -> Locale:
from importlib import import_module, resources
from importlib import import_module
from importlib import resources

if isinstance(locale, Locale):
return locale

locale = cls.normalize_locale(locale)
if locale == "uk":
locale = "ua"
if locale in cls._cache:
return cls._cache[locale]

Expand Down Expand Up @@ -93,7 +95,7 @@ def match_translation(self, key: str, value: Any) -> dict[str, str] | None:
if value not in translations.values():
return None

return cast(Dict[str, str], {v: k for k, v in translations.items()}[value])
return cast(dict[str, str], {v: k for k, v in translations.items()}[value])

def __repr__(self) -> str:
return f"{self.__class__.__name__}('{self._locale}')"