feat: added translations
This commit is contained in:
parent
02a7c29dba
commit
6ed94db8cf
@ -85,6 +85,7 @@ class ArticleTranslation:
|
||||
self.dist_path = Path(config.setup.dist_directory, *self.location_in_tree)
|
||||
|
||||
self.priority = LANGUAGES[self.language_code]["priority"]
|
||||
self.real_language_code = LANGUAGES[self.language_code]["code"]
|
||||
|
||||
# TODO remove
|
||||
self.article_content = self.file.read_text()
|
||||
@ -191,16 +192,25 @@ class Article:
|
||||
at.__init_context__()
|
||||
self.__init_context__()
|
||||
|
||||
import json
|
||||
print(json.dumps(self.context, indent=4))
|
||||
|
||||
|
||||
|
||||
def __init_context__(self):
|
||||
self.context["url"] = self.url
|
||||
self.context_meta["slug"] = self.slug
|
||||
|
||||
modified_at = datetime.fromisoformat(article_config["datetime"]) if "datetime" in article_config else datetime.fromtimestamp(self.directory.stat().st_mtime)
|
||||
modified_at = datetime.fromisoformat(self.config["datetime"]) if "datetime" in self.config else datetime.fromtimestamp(self.directory.stat().st_mtime)
|
||||
self.context_meta["date"] = modified_at.strftime(config.formatting.datetime_format)
|
||||
self.context_meta["iso_date"] = modified_at.isoformat()
|
||||
|
||||
# add translations to context
|
||||
translation_list = self.context["translations"] = []
|
||||
for article_translation in self.article_translations_list:
|
||||
self.context[article_translation.real_language_code] = article_translation.context
|
||||
translation_list.append(article_translation.context)
|
||||
|
||||
|
||||
|
||||
def build(self):
|
||||
@ -264,4 +274,4 @@ def build():
|
||||
ARTICLE_REFERENCE_VALUES[language_code].update(at.get_article_values())
|
||||
|
||||
logger.info("writing page tree...")
|
||||
tree.build()
|
||||
# tree.build()
|
Loading…
x
Reference in New Issue
Block a user