Commit 180b7118 authored by lunasorcery's avatar lunasorcery
Browse files

prepare for localized meta descriptions

parent 2b11ba7c
......@@ -23,6 +23,7 @@ def crc32_file(filename):
# WIP language feature
enableLanguageDropdown = True
validateMissingLocalization = True
localizedMetaDesc = False
# Seasonal events
......@@ -197,7 +198,7 @@ for lang in languages:
with open(f"languages/{lang['id']}.json") as file:
langData = json.load(file)
def template_localize(text, render):
def localize(text):
keys = text.strip().split('.')
value = langData
for key in keys:
......@@ -208,7 +209,10 @@ for lang in languages:
else:
return f"[[{text.strip()}]]"
value = value[key]
return render(value)
return value
def template_localize(text, render):
return render(localize(text))
langTemplate = { 'i18n': template_localize }
......@@ -218,7 +222,7 @@ for lang in languages:
template = f,
partials_path = 'templates/',
data = sharedTemplate | langTemplate | {
'meta-description': "A curated gallery of 4K Executable Graphics works from the demoscene.",
'meta-description': localize('meta.desc-gallery') if localizedMetaDesc else "A curated gallery of 4K Executable Graphics works from the demoscene.",
'meta-twitter-card-type': "summary_large_image",
'currpage-canonical-filename' : '',
'page-gallery': True,
......@@ -230,8 +234,8 @@ for lang in languages:
template = f,
partials_path = 'templates/',
data = sharedTemplate | langTemplate | {
'meta-subtitle': "Meteoriks",
'meta-description': "Nominees and winners of the 'Best Executable Graphics' Meteorik award.",
'meta-subtitle': localize('nav.meteoriks'),
'meta-description': localize('meta.desc-meteoriks') if localizedMetaDesc else "Nominees and winners of the 'Best Executable Graphics' Meteorik award.",
'meta-twitter-card-type': "summary",
'meta-image': meteorikProds[0]['image_url'],
'currpage-canonical-filename' : 'meteoriks.html',
......@@ -244,8 +248,8 @@ for lang in languages:
template = f,
partials_path = 'templates/',
data = sharedTemplate | langTemplate | {
'meta-subtitle': "About",
'meta-description': "What is Executable Graphics?",
'meta-subtitle': localize('nav.about'),
'meta-description': localize('meta.desc-about') if localizedMetaDesc else "What is Executable Graphics?",
'meta-twitter-card-type': "summary",
'currpage-canonical-filename' : 'about.html',
'page-about': True }))
{
"meta": {
"desc-gallery": "A curated gallery of 4K Executable Graphics works from the demoscene.",
"desc-meteoriks": "Nominees and winners of the 'Best Executable Graphics' Meteorik award.",
"desc-about": "What is Executable Graphics?"
},
"global": {
"toggle-theme": "Toggle Theme",
"toggle-lang": "Language"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment