diff options
author | Florian Dold <florian@dold.me> | 2021-02-17 15:07:30 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-02-17 15:07:43 +0100 |
commit | 99a0de7cac0033db10a0bed9f476900ece1e402a (patch) | |
tree | a7c594f9f3177f3737d6d7aa7916a44ffb05c58b | |
parent | 4ae188ae658793c6cfddf60fdb5a563e590f9cfa (diff) | |
download | www_shared-99a0de7cac0033db10a0bed9f476900ece1e402a.tar.gz www_shared-99a0de7cac0033db10a0bed9f476900ece1e402a.zip |
better error messages
-rw-r--r-- | site.py | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -147,14 +147,23 @@ class gen_site: | |||
147 | # locale = os.path.basename(l[:-1]) | 147 | # locale = os.path.basename(l[:-1]) |
148 | locale = l | 148 | locale = l |
149 | 149 | ||
150 | tr = gettext.translation("messages", | 150 | |
151 | localedir="locale", | 151 | try: |
152 | languages=[locale]) | 152 | tr = gettext.translation("messages", |
153 | localedir="locale", | ||
154 | languages=[locale]) | ||
155 | except FileNotFoundError as e: | ||
156 | print(f"WARNING: unable to find translations for locale '{locale}'", file=sys.stderr) | ||
157 | continue | ||
153 | 158 | ||
154 | tr.gettext = i18nfix.wrap_gettext(tr.gettext) | 159 | tr.gettext = i18nfix.wrap_gettext(tr.gettext) |
155 | 160 | ||
156 | env.install_gettext_translations(tr, newstyle=True) | 161 | env.install_gettext_translations(tr, newstyle=True) |
157 | 162 | ||
163 | if locale not in conf["langs_full"]: | ||
164 | print(f"WARNING: skipping '{locale}, as 'langs_full' is not configured'", file=sys.stderr) | ||
165 | continue | ||
166 | |||
158 | content = tmpl.render(lang=locale, | 167 | content = tmpl.render(lang=locale, |
159 | lang_full=conf["langs_full"][locale], | 168 | lang_full=conf["langs_full"][locale], |
160 | url=url, | 169 | url=url, |
@@ -186,7 +195,7 @@ class gen_site: | |||
186 | 195 | ||
187 | try: | 196 | try: |
188 | langdir.mkdir(parents=True, exist_ok=True) | 197 | langdir.mkdir(parents=True, exist_ok=True) |
189 | except e as FileNotFoundError: | 198 | except FileNotFoundError as e: |
190 | print(e) | 199 | print(e) |
191 | 200 | ||
192 | with codecs.open(out_name, "w", encoding='utf-8') as f: | 201 | with codecs.open(out_name, "w", encoding='utf-8') as f: |