Commit 312f94de authored by lunasorcery's avatar lunasorcery
Browse files

getting closer to full i18n support

parent bd3012c6
......@@ -2,7 +2,7 @@
<div class="content">
<div class="content-thing slim">
<div class="text">
<span class="question">{{i18n.about.what-is-exegfx}}</span>
<span class="question">{{#i18n}}about.what-is-exegfx{{/i18n}}</span>
<div class="answer">
<p>
In the purest sense, Executable Graphics is visual artwork through the medium of software.
......@@ -18,7 +18,7 @@
</p>
</div>
<br/>
<span class="question">{{i18n.about.what-is-exe-dot-gfx}}</span>
<span class="question">{{#i18n}}about.what-is-exe-dot-gfx{{/i18n}}</span>
<div class="answer">
<p>
This website presents a gallery of artworks from various artists in the Executable Graphics scene.
......
......@@ -2,17 +2,17 @@
<div class="content-thing">
<a href="{{demozoo_url}}" style="display:block">
{{#meteorik-nominee}}
<div class="meteorik meteorik-nominee">Meteoriks {{meteorik-year}} Nominee</div>
<div class="meteorik meteorik-nominee">{{#i18n}}badges.meteorik-nominee{{/i18n}}</div>
{{/meteorik-nominee}}
{{#meteorik-winner}}
<div class="meteorik meteorik-winner">Meteoriks {{meteorik-year}} Winner</div>
<div class="meteorik meteorik-winner">{{#i18n}}badges.meteorik-winner{{/i18n}}</div>
{{/meteorik-winner}}
<div class="text">
<span class="author">{{author}}</span>
<br/>
<span class="title">{{title}}</span>, <span class="party">{{party}}</span>
<br/>
<span class="subtitle">{{platform}} executable</span>
<span class="subtitle">{{#i18n}}artwork.platform{{/i18n}}</span>
</div>
<div class="image">
<img src="{{image_url}}" loading="lazy"/>
......
......@@ -22,6 +22,7 @@ def crc32_file(filename):
# WIP features
enableLanguageDropdown = False
enableDebugLanguage = False
validateMissingLocalization = True
......@@ -136,10 +137,11 @@ if enableDebugLanguage:
'enabled': False,
'data': {}
}
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}]]"
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)
......@@ -158,18 +160,28 @@ for lang in i18n:
sharedTemplate = {
'meta-title': "executable.graphics",
'meta-image': prods[0]['image_url'],
'current-year': datetime.datetime.now().year,
'meteoriks-juror-application-open': False,
'meteoriks-nominations-open': False,
'enable-language-dropdown': enableLanguageDropdown,
'languages': langDropdown,
'external-url-meteoriks': 'https://meteoriks.org/',
'external-url-meteoriks-jurors': 'https://meteoriks.org/taking_part/juror',
'external-url-pouet': 'https://pouet.net/',
'external-url-demozoo': 'https://demozoo.org/',
'hash-fonts-css': crc32_file('fonts.css'),
'hash-style-css': crc32_file('style.css'),
'hash-favicon-ico': crc32_file('gen/favicon.ico'),
'hash-apple-touch-icon-png': crc32_file('gen/apple-touch-icon.png'),
'hash-manifest-json': crc32_file('manifest.json'),
'svg-globe': open('globe.svg').read(),
'svg-moon': open('moon.svg').read(),
'enable-language-dropdown': enableLanguageDropdown,
'languages': langDropdown
'svg-moon': open('moon.svg').read()
}
......@@ -180,7 +192,20 @@ for lang in i18n:
outdir += '/' + lang['id']
maybe_mkdir(outdir)
langTemplate = { 'i18n': lang['data'] }
def template_localize(text, render):
keys = text.strip().split('.')
value = lang['data']
for key in keys:
if key not in value:
if validateMissingLocalization:
print(f"ERROR: Missing i18n key '{text}' for language '{lang['name']}'")
quit()
else:
return f"[[{text.strip()}]]"
value = value[key]
return render(value)
langTemplate = { 'i18n': template_localize }
with open('index.mustache', 'r') as f:
with open(f"{outdir}/index.html", 'w') as fout:
......
......@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<title>{{meta-title}}{{#meta-subtitle}} | {{meta-subtitle}}{{/meta-subtitle}}</title>
<meta property="og:title" content="{{meta-title}}{{#meta-subtitle}} | {{meta-subtitle}}{{/meta-subtitle}}"/>
......@@ -30,10 +30,10 @@
</head>
<body>
{{#enable-language-dropdown}}
<div class="switch switch-left switch-lang" tabindex="0">
<label class="switch-label switch-label-left">
<div class="switch switch-left switch-dropdown" id="switch-lang" tabindex="0">
<label class="label">
{{{svg-globe}}}
<span>{{i18n.global.toggle-lang}}</span>
<span>{{#i18n}}global.toggle-lang{{/i18n}}</span>
</label>
<div class="mousetrap">
<ul class="dropdown">
......@@ -53,15 +53,15 @@
</div>
{{/enable-language-dropdown}}
<div class="navbar">
<a href="." class="entry{{#page-gallery}} active{{/page-gallery}}">{{i18n.nav.gallery}}</a>
<a href="meteoriks.html" class="entry{{#page-meteoriks}} active{{/page-meteoriks}}">{{i18n.nav.meteoriks}}</a>
<a href="about.html" class="entry{{#page-about}} active{{/page-about}}">{{i18n.nav.about}}</a>
<a href="." class="entry{{#page-gallery}} active{{/page-gallery}}">{{#i18n}}nav.gallery{{/i18n}}</a>
<a href="meteoriks.html" class="entry{{#page-meteoriks}} active{{/page-meteoriks}}">{{#i18n}}nav.meteoriks{{/i18n}}</a>
<a href="about.html" class="entry{{#page-about}} active{{/page-about}}">{{#i18n}}nav.about{{/i18n}}</a>
</div>
<div class="switch switch-right switch-theme" tabindex="0">
<label class="switch-label switch-label-right" for="theme-checkbox">
<span>{{i18n.global.toggle-theme}}</span>
<div class="switch switch-right switch-toggle" id="switch-theme">
<input type="checkbox" id="theme-checkbox" />
<label class="label" for="theme-checkbox">
<span>{{#i18n}}global.toggle-theme{{/i18n}}</span>
{{{svg-moon}}}
<input type="checkbox" id="theme-checkbox" />
</label>
</div>
<script src="/script.js"></script>
......@@ -13,8 +13,17 @@
"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": "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?",
......@@ -31,7 +40,34 @@
{
"id": "jp",
"name": "日本語",
"enabled": false,
"data": { }
"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
......@@ -2,22 +2,18 @@
<div class="content">
<div class="content-thing slim">
<div class="text">
<span class="question">{{i18n.meteoriks.what-are-meteoriks}}</span>
<span class="question">{{#i18n}}meteoriks.what-are-meteoriks{{/i18n}}</span>
<div class="answer">
<p>
<a href="https://meteoriks.org/">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.
</p>
<p>
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.
</p>
<p>{{#i18n}}meteoriks.what-are-meteoriks-p1{{/i18n}}</p>
<p>{{#i18n}}meteoriks.what-are-meteoriks-p2{{/i18n}}</p>
{{#meteoriks-juror-application-open}}
<p>
Applications to be a juror for the {{current-year}} Meteoriks are <a href="https://meteoriks.org/taking_part/juror">now open</a>!
Applications to be a juror for the {{current-year}} Meteoriks are <a href="{{external-url-meteoriks-jurors}}">now open</a>!
</p>
{{/meteoriks-juror-application-open}}
{{#meteoriks-nominations-open}}
<p>
Public nominations for the {{current-year}} Meteoriks are now open - you can submit entries for the jurors' consideration through both <a href="https://www.pouet.net/">Pouët</a> and <a href="https://demozoo.org/">Demozoo</a>.
Public nominations for the {{current-year}} Meteoriks are now open - you can submit entries for the jurors' consideration through both <a href="{{external-url-pouet}}">Pouët</a> and <a href="{{external-url-demozoo}}">Demozoo</a>.
</p>
{{/meteoriks-nominations-open}}
</div>
......
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