This commit is contained in:
Maxim Khomutov 2025-03-23 04:11:03 +03:00
parent 0b9f8b6feb
commit f26cc65c7f

View File

@ -17,8 +17,13 @@ class NestedAccessor:
def __init__(self, parent, key_chain):
self.parent: "I18N" = parent
self.key_chain = key_chain
self.__name__ = f'<{".".join(key_chain)}>'.upper()
def __getattr__(self, item):
key = ".".join((*self.key_chain, item))
print(key, key in self.parent.locale)
if key in self.parent.locale:
return self.parent.get_phrase(key)
if item.startswith("__"): # Проверяем системные атрибуты
raise AttributeError(f"'{item}' is not accessible")
return NestedAccessor(self.parent, self.key_chain + [item])