Browse Source

use flags for languages

april1st
Alexandros Theodotou 3 years ago
parent
commit
ef464b0aca
  1. 2
      .gitignore
  2. 11
      common/navigation.j2.inc
  3. 2
      locale/messages.pot
  4. 4
      template.py

2
.gitignore vendored

@ -23,3 +23,5 @@ __pycache__ @@ -23,3 +23,5 @@ __pycache__
\#*\#
futility_engine_loader.sh
# vim files
*.swp

11
common/navigation.j2.inc

@ -90,15 +90,12 @@ @@ -90,15 +90,12 @@
<a class="nav-link dropdown-toggle" href="#"
data-toggle="dropdown" role="button"
aria-haspopup="true" aria-expanded="false">
{{ lang_full }} [{{ lang }}]
{{ lang_full }} {{ lang_flag }}
</a>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarMain">
<li><a class="dropdown-item" href="{{ self_localized('en') }}">English [en]</a></li>
<li><a class="dropdown-item" href="{{ self_localized('de') }}">Deutsch [de]</a></li>
<li><a class="dropdown-item" href="{{ self_localized('fr') }}">Fran&ccedil;ais [fr]</a></li>
<li><a class="dropdown-item" href="{{ self_localized('it') }}">Italiano [it]</a></li>
<li><a class="dropdown-item" href="{{ self_localized('es') }}">Espa&ntilde;ol [es]</a></li>
<li><a class="dropdown-item" href="{{ self_localized('ja') }}">日本語 [ja]</a></li>
{% for key in langs_full.keys() %}
<li><a class="dropdown-item" href="{{ self_localized(key) }}">{{ lang_flags[key] }} {{ langs_full[key] }}</a></li>
{% endfor %}
</ul>
</li> <!-- /navbar-right dropdown -->
</ul> <!-- /navbar-right -->

2
locale/messages.pot

@ -8,7 +8,7 @@ msgid "" @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2019-04-19 12:03+0100\n"
"POT-Creation-Date: 2019-04-26 11:08+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

4
template.py

@ -33,6 +33,7 @@ if (os.getenv("DEBUG")): @@ -33,6 +33,7 @@ if (os.getenv("DEBUG")):
print(sys.path)
langs_full = {"en": "English", "fr": "Français", "it": "Italiano", "es": "Español", "de": "Deutsch", "ja": "日本語"}
lang_flags = {"en": "🇬🇧", "fr": "🇫🇷", "it": "🇮🇹", "es": "🇪🇸", "de": "🇩🇪", "ja": "🇯🇵"}
for in_file in glob.glob("template/*.j2"):
name, ext = re.match(r"(.*)\.([^.]+)$", in_file.rstrip(".j2")).groups()
@ -71,7 +72,10 @@ for in_file in glob.glob("template/*.j2"): @@ -71,7 +72,10 @@ for in_file in glob.glob("template/*.j2"):
env.install_gettext_translations(tr, newstyle=True)
content = tmpl.render(lang=locale,
lang_flag=lang_flags[locale],
lang_flags=lang_flags,
lang_full=langs_full[locale],
langs_full=langs_full,
url=url,
self_localized=self_localized,
url_localized=url_localized,

Loading…
Cancel
Save