Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: switch language based on current path #16687

Merged
merged 4 commits into from Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/_data/sites/en.yml
Expand Up @@ -85,6 +85,7 @@ footer:
description: Selecting a language will take you to the ESLint website in that language.
change_language: Change Language
language: Language
latest: Latest
copyright: >
&copy; OpenJS Foundation and ESLint contributors, <a href="https://www.openjsf.org">www.openjsf.org</a>
links:
Expand Down
1 change: 1 addition & 0 deletions docs/src/_data/sites/zh-hans.yml
Expand Up @@ -84,6 +84,7 @@ footer:
description: 切换到你所选择语言版本对应的 ESLint 网站。
change_language: 更改语言
language: 语言
latest: 最新
copyright: >
&copy; OpenJS Foundation and ESLint contributors, <a href="https://www.openjsf.org">www.openjsf.org</a>
links:
Expand Down
9 changes: 7 additions & 2 deletions docs/src/_includes/components/language-switcher.html
Expand Up @@ -14,9 +14,14 @@
<select name="language selector" id="language-select" aria-describedby="language-infobox"
class="c-custom-select switcher__select">
{% for key, other_site in sites %}
<option value="{{ other_site.language.code }}" data-url="https://{{ other_site.hostname }}" {% if
site.language.code==other_site.language.code %} selected {% endif %}>
<option
value="{{ other_site.language.code }}"
kecrily marked this conversation as resolved.
Show resolved Hide resolved
data-url="https://{{ other_site.hostname }}/docs/latest{{ page.url | prettyURL }}"
{% if site.language.code==other_site.language.code %}selected{% endif %}
>
{{ other_site.language.flag }} {{ other_site.language.name }}
{% if site.language.code!=other_site.language.code %}({{ other_site.footer.language_switcher.latest }})
{% elif GIT_BRANCH=="latest" %}({{ other_site.footer.language_switcher.latest }}){% endif %}
kecrily marked this conversation as resolved.
Show resolved Hide resolved
</option>
{% endfor %}
</select>
Expand Down