Commit a2e0692f authored by lunasorcery's avatar lunasorcery
Browse files

further cleanup for language support

parent 6d4a0e09
......@@ -21,13 +21,12 @@ def crc32_file(filename):
# WIP features
enableLanguageDropdown = False
enableDebugLanguage = False
validateMissingLocalization = True
with open('i18n.json') as file:
i18n = [lang for lang in json.load(file) if lang.get('enabled', True)]
with open('languages/list.json') as file:
languages = json.load(file)
# load prods
with open('prods.json') as file:
......@@ -128,35 +127,6 @@ for idx,prod in enumerate(prods):
raise hell
# add debug lang
if enableDebugLanguage:
devLang = {
'id': "i18n-debug",
'name': "Debug",
'enabled': False,
'data': {}
}
if validateMissingLocalization:
for key in i18n[0]['data'].keys():
devLang['data'][key] = {}
for key2 in i18n[0]['data'][key].keys():
devLang['data'][key][key2] = f"[[{key}.{key2}]]"
i18n.append(devLang)
# prepare language dropdown
langDropdown = []
for lang in i18n:
dropdownEntry = {}
dropdownEntry['lang-name'] = lang['name']
if lang['id'] == 'en':
dropdownEntry['lang-root'] = ""
else:
dropdownEntry['lang-root'] = f"/{lang['id']}"
langDropdown.append(dropdownEntry)
sharedTemplate = {
'meta-title': "executable.graphics",
'meta-image': prods[0]['image_url'],
......@@ -167,7 +137,7 @@ sharedTemplate = {
'meteoriks-nominations-open': False,
'enable-language-dropdown': enableLanguageDropdown,
'languages': langDropdown,
'languages': languages,
'external-url-meteoriks': 'https://meteoriks.org/',
'external-url-meteoriks-jurors': 'https://meteoriks.org/taking_part/juror',
......@@ -186,15 +156,15 @@ sharedTemplate = {
print("applying templates...")
for lang in i18n:
outdir = 'gen'
if lang['id'] != 'en':
outdir += '/' + lang['id']
for lang in languages:
outdir = f"gen{lang['root']}"
maybe_mkdir(outdir)
with open(f"languages/{lang['id']}.json") as file:
langData = json.load(file)
def template_localize(text, render):
keys = text.strip().split('.')
value = lang['data']
value = langData
for key in keys:
if key not in value:
if validateMissingLocalization:
......@@ -215,6 +185,7 @@ for lang in i18n:
data = sharedTemplate | langTemplate | {
'meta-description': "A curated gallery of 4K Executable Graphics works from the demoscene.",
'meta-twitter-card-type': "summary_large_image",
'currpage-canonical-filename' : '',
'page-gallery': True,
'entries': prods }))
......@@ -228,6 +199,7 @@ for lang in i18n:
'meta-description': "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',
'page-meteoriks': True,
'entries': meteorikProds }))
......@@ -240,4 +212,5 @@ for lang in i18n:
'meta-subtitle': "About",
'meta-description': "What is Executable Graphics?",
'meta-twitter-card-type': "summary",
'currpage-canonical-filename' : 'about.html',
'page-about': True }))
[
{
"id": "en",
"name": "English",
"enabled": true,
"data": {
"global": {
"toggle-theme": "Toggle Theme",
"toggle-lang": "Language"
},
"nav": {
"gallery": "Gallery",
"meteoriks": "Meteoriks",
"about": "About"
},
"artwork": {
"platform": "{{platform}} executable"
},
"badges": {
"meteorik-nominee": "Meteoriks {{meteorik-year}} Nominee",
"meteorik-winner": "Meteoriks {{meteorik-year}} Winner"
},
"meteoriks": {
"what-are-meteoriks": "What are the Meteoriks?",
"what-are-meteoriks-p1": "<a href=\"{{external-url-meteoriks}}\">The Meteoriks</a> are an award to honor the best productions that the demoscene has to offer, and are presented annually at the Revision demoparty over the Easter weekend.",
"what-are-meteoriks-p2": "Following a surge of activity in the Executable Graphics field, the Meteoriks introduced a category for Best Executable Graphics in 2021. You can see the nominees and winner below."
},
"about": {
"what-is-exegfx": "What is Executable Graphics?",
"what-is-exe-dot-gfx": "What is executable.graphics?"
}
}
},
{
"id": "es",
"name": "Español",
"enabled": false,
"data": { }
},
{
"id": "jp",
"name": "日本語",
"enabled": true,
"comment": "this is all placeholder google-translate, don't use it on the live site!",
"data": {
"global": {
"toggle-theme": "テーマを切り替える",
"toggle-lang": "言語"
},
"nav": {
"gallery": "ギャラリー",
"meteoriks": "メテオリック",
"about": "約"
},
"artwork": {
"platform": "{{platform}} 実行可能ファイル"
},
"badges": {
"meteorik-nominee": "メテオリック {{meteorik-year}} の候補者",
"meteorik-winner": "メテオリック {{meteorik-year}} 優勝"
},
"meteoriks": {
"what-are-meteoriks": "メテオリックとは?",
"what-are-meteoriks-p1": "<a href=\"{{external-url-meteoriks}}\">Meteoriks は</a>、デモシーンが提供しなければならない最高の作品を表彰する賞であり、イースターの週末にリビジョン デモパーティーで毎年発表されます。",
"what-are-meteoriks-p2": "Executable Graphics カテゴリでの活動が急増した後、Meteoriks は 2021 年に Best Executable Graphics のカテゴリを導入しました。以下にノミネートと受賞者を示します。"
},
"about": {
"what-is-exegfx": "実行可能なグラフィックスとは何ですか?",
"what-is-exe-dot-gfx": "executable.graphics とは何ですか?"
}
}
}
]
\ No newline at end of file
{
"global": {
"toggle-theme": "Toggle Theme",
"toggle-lang": "Language"
},
"nav": {
"gallery": "Gallery",
"meteoriks": "Meteoriks",
"about": "About"
},
"artwork": {
"platform": "{{platform}} executable"
},
"badges": {
"meteorik-nominee": "Meteoriks {{meteorik-year}} Nominee",
"meteorik-winner": "Meteoriks {{meteorik-year}} Winner"
},
"meteoriks": {
"what-are-meteoriks": "What are the Meteoriks?",
"what-are-meteoriks-p1": "<a href=\"{{external-url-meteoriks}}\">The Meteoriks</a> are an award to honor the best productions that the demoscene has to offer, and are presented annually at the Revision demoparty over the Easter weekend.",
"what-are-meteoriks-p2": "Following a surge of activity in the Executable Graphics field, the Meteoriks introduced a category for Best Executable Graphics in 2021. You can see the nominees and winner below."
},
"about": {
"what-is-exegfx": "What is Executable Graphics?",
"what-is-exe-dot-gfx": "What is executable.graphics?"
}
}
{
"comment": "NOTE: this is all placeholder google translate, replace it with a real translation before setting the feature live!",
"global": {
"toggle-theme": "テーマを切り替える",
"toggle-lang": "言語"
},
"nav": {
"gallery": "ギャラリー",
"meteoriks": "メテオリック",
"about": "約"
},
"artwork": {
"platform": "{{platform}} 実行可能ファイル"
},
"badges": {
"meteorik-nominee": "メテオリック {{meteorik-year}} の候補者",
"meteorik-winner": "メテオリック {{meteorik-year}} 優勝"
},
"meteoriks": {
"what-are-meteoriks": "メテオリックとは?",
"what-are-meteoriks-p1": "<a href=\"{{external-url-meteoriks}}\">Meteoriks は</a>、デモシーンが提供しなければならない最高の作品を表彰する賞であり、イースターの週末にリビジョン デモパーティーで毎年発表されます。",
"what-are-meteoriks-p2": "Executable Graphics カテゴリでの活動が急増した後、Meteoriks は 2021 年に Best Executable Graphics のカテゴリを導入しました。以下にノミネートと受賞者を示します。"
},
"about": {
"what-is-exegfx": "実行可能なグラフィックスとは何ですか?",
"what-is-exe-dot-gfx": "executable.graphics とは何ですか?"
}
}
[
{
"id": "en",
"name": "English",
"root": ""
},
{
"id": "jp",
"name": "日本語",
"root": "/jp"
}
]
\ No newline at end of file
......@@ -38,15 +38,7 @@
<div class="mousetrap">
<ul class="dropdown">
{{#languages}}
{{#page-gallery}}
<a href="{{lang-root}}/" class="item" tabindex="0">{{lang-name}}</a>
{{/page-gallery}}
{{#page-meteoriks}}
<a href="{{lang-root}}/meteoriks.html" class="item" tabindex="0">{{lang-name}}</a>
{{/page-meteoriks}}
{{#page-about}}
<a href="{{lang-root}}/about.html" class="item" tabindex="0">{{lang-name}}</a>
{{/page-about}}
<a href="{{root}}/{{currpage-canonical-filename}}" class="item" tabindex="0">{{name}}</a>
{{/languages}}
</ul>
</div>
......
Supports Markdown
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