Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only list languages that have the current article translated
The language switcher listed every locale regardless of whether the
current article had a translation in it. Picking an untranslated
language for an article-type page sent the reader to a 404, since
loadLanguage() in assets/js/locale.js rewrites the URL's language
segment without checking the target page exists.

Filter the dropdown at render time using the same
site.articles | where: 'lang' / where: 'class' lookup already used in
_layouts/article.html for related-article links, so only languages that
actually carry a translation of the current article are offered. Non-article
pages (index, static pages) are unaffected since every locale ships those.
  • Loading branch information
czllll committed Aug 22, 2026
commit e9feb5770aa24de5f72bdfb92deaf67d42db181d
6 changes: 6 additions & 0 deletions _includes/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
{% for locale in locales %}
{% assign lang = locale[0] %}
{% assign locale_name = locale[1][lang].locale_name %}
{% if page.layout == 'article' and lang != page.lang %}
{% assign translated_article = site.articles | where: 'lang', lang | where: 'class', page.class | first %}
{% unless translated_article %}
{% continue %}
{% endunless %}
{% endif %}
{% if page.lang == lang %}
<option value="{{ lang }}" selected="selected">{{ locale_name }}</option>
{% else %}
Expand Down
Loading