fix: fix content cached between languages

This commit is contained in:
Corentin 2024-05-21 15:34:32 +02:00
parent e898505125
commit 8591ae53fa
1 changed files with 4 additions and 1 deletions

View File

@ -33,10 +33,12 @@ class ContentDirectory(Content):
for item in self.path.glob(pattern):
yield self.load(str(item.relative_to(self.path)))
@cache # noqa: B019
def __load_children(self, name: str) -> Content:
child_path = self.__get_localized_path(self.path / name)
return self.__load_path(child_path)
@cache # noqa: B019
def __load_path(self, child_path: Path) -> Content:
if not child_path.exists():
raise FileNotFoundError(child_path)
@ -56,6 +58,7 @@ class ContentDirectory(Content):
if Content.current_language is None:
return path
localized_path = path.with_name(f"{path.stem}-{Content.current_language}{path.suffix}")
print(localized_path)
if not localized_path.exists():
return path