Skip to content

Commit

Permalink
Merge pull request #119 from gaphor/language-dropdown
Browse files Browse the repository at this point in the history
Move language selection to dropdown menu
  • Loading branch information
danyeaw authored Apr 23, 2023
2 parents c071324 + af6a529 commit d4b6480
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 22 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ permalink: pretty

include:
- "_pages"
- "js"
- .well-known
collections:
usps:
Expand Down Expand Up @@ -87,5 +88,6 @@ exclude_from_localization:
- .gitignore
- CNAME
- css/
- js/
- images
- po/
10 changes: 10 additions & 0 deletions _data/languagenames.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"en": "English",
"es": "Español",
"cs": "Čeština",
"nl": "Nederlands",
"hr": "Hrvatski",
"hu": "Magyar",
"ru": "Русский",
"tr": "Türkçe"
}
17 changes: 0 additions & 17 deletions _data/languages.yml

This file was deleted.

2 changes: 2 additions & 0 deletions _data/strings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ footer:
tech-docs: Tech docs
copyright: Copyright © 2020-2023 Arjan Molenaar and Dan Yeaw.
theme: Theme
languages:
change: Change
23 changes: 18 additions & 5 deletions _includes/languages.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<nav class="col-12 d-flex justify-content-end language-navigation">
<ul>
{% for item in site.data.languages.languages %}
<li><a {% static_href %}href="{{ site.baseurl | append: item.url | append: page.url }}"{% endstatic_href %}>{{ item.title }}</a></li>
{% endfor %}
</ul>

<form action="{{ site.baseurl }}{{ page.url }}" method="get">

<select id="language-chooser-select" name="lang" autocomplete="off">
{% for lang in site.languages %}
<option value="{{ lang }}" {% if lang== site.active_lang %}selected="selected" {% endif %}>
{{ site.data.languagenames[lang] }}
</option>
{% endfor %}
</select>

<script src="/js/languages.js" async></script>

<noscript>
<input id="language-chooser-submit" type="submit" value="{{ site.data.strings.languages.change }}"/>
</noscript>

</form>
</nav>
2 changes: 2 additions & 0 deletions _pages/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ and expectations for the various types of contribution you can make to Gaphor.

The source code is hosted on [GitHub](https://github.com/gaphor/gaphor).

Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/).

If in doubt, just ask in our <a href="../discuss">discussion area</a> and
someone will be able to point you in the right direction.
19 changes: 19 additions & 0 deletions js/languages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

const chooser = document.getElementById('language-chooser-select');
let activeLang = 'en';
for (let i = 0; i < chooser.children.length; i++) {
if (chooser.children[i].selected) {
activeLang = chooser.children[i].value;
}
}

chooser.onchange = function() {
const lang = this.value;
let pageUrl = document.location.pathname;

if (new RegExp('^/' + activeLang + '/').test(pageUrl)) {
pageUrl = pageUrl.substring(activeLang.length + 1);
}

document.location = '' + '/' + lang + pageUrl;
}
5 changes: 5 additions & 0 deletions po/site.cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ msgstr "Naše technická dokumentace je umístěna na skvělé službě Read the
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr "Zdrojový kód je umístěn na GitHubu."

#. type: Plain text
#: _pages/contribute.md
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, fuzzy, no-wrap
Expand Down
5 changes: 5 additions & 0 deletions po/site.es.po
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ msgstr "Nuestra documentación técnica está alojada en el maravilloso servicio
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr "El código fuente está alojado en GitHub."

#. type: Plain text
#: _pages/contribute.md
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, fuzzy, no-wrap
Expand Down
5 changes: 5 additions & 0 deletions po/site.hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ msgstr "Naša se [tehnička dokumentacija](https://docs.gaphor.org/hr/latest) č
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr "Izvorni kod se nalazi na [GitHubu](https://github.com/gaphor/gaphor)."

#. type: Plain text
#: _pages/contribute.md
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, no-wrap
Expand Down
5 changes: 5 additions & 0 deletions po/site.hu.po
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ msgstr ""
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, no-wrap
Expand Down
5 changes: 5 additions & 0 deletions po/site.nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ msgstr "Onze technische documentatie wordt gehost op de prachtige dienst Read th
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr "De broncode is beschikbaar op GitHub."

#. type: Plain text
#: _pages/contribute.md
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, fuzzy, no-wrap
Expand Down
6 changes: 6 additions & 0 deletions po/site.pot
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ msgstr ""
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, markdown-text
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, markdown-text, no-wrap
Expand Down
5 changes: 5 additions & 0 deletions po/site.ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@ msgstr ""
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, no-wrap
Expand Down
5 changes: 5 additions & 0 deletions po/site.tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ msgstr ""
msgid "The source code is hosted on [GitHub](https://github.com/gaphor/gaphor)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
msgid "Help translate Gaphor on [Weblate](https://hosted.weblate.org/engage/gaphor/)."
msgstr ""

#. type: Plain text
#: _pages/contribute.md
#, no-wrap
Expand Down

0 comments on commit d4b6480

Please sign in to comment.