29 lines
826 B
Python
Executable file
29 lines
826 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import jinja2
|
|
import os
|
|
import shutil
|
|
import yaml
|
|
|
|
|
|
with open('config.yml', 'r') as f:
|
|
config = yaml.safe_load(f)
|
|
|
|
os.makedirs('out', exist_ok = True)
|
|
shutil.copytree('static', 'out/static', dirs_exist_ok=True)
|
|
|
|
for lang in config['languages'].keys():
|
|
with open(f'l10n/{lang}.yml', 'r') as l:
|
|
l10n = yaml.safe_load(l)
|
|
|
|
env = jinja2.Environment(loader=jinja2.FileSystemLoader("src"))
|
|
env.globals.update(config['jinja_environment'])
|
|
env.globals.update(l10n)
|
|
env.globals['languages'] = config['languages']
|
|
env.globals['lang'] = lang
|
|
|
|
os.makedirs(os.path.join('out', lang), exist_ok = True)
|
|
for fname in os.listdir('src'):
|
|
tmpl = env.get_template(fname)
|
|
with open(os.path.join('out', lang, fname), 'w') as of:
|
|
of.write(tmpl.render())
|