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

💻 Language switcher text #5309

Merged
merged 5 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import sys
import traceback
import textwrap
import unicodedata
import zipfile
import jinja_partials
from typing import Optional
Expand Down Expand Up @@ -414,6 +415,9 @@ def setup_language():
# front-end is fixed based on this value
g.dir = static_babel_content.TEXT_DIRECTIONS.get(g.lang, 'ltr')

# True if it is a Latin alphabet, False if not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this comment! This is exactly the type of thing that is very easy to understand/explain and superhard to get from the code!

g.latin = all('LATIN' in unicodedata.name(char, '').upper() for char in current_language()['sym'])

# Check that requested language is supported, otherwise return 404
if g.lang not in ALL_LANGUAGES.keys():
return "Language " + g.lang + " not supported", 404
Expand Down
2 changes: 1 addition & 1 deletion templates/level-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h2 class="px-2 py-6">{{_('cheatsheet_title')}}</h2>
<div class="dropdown relative">
<button class="green-btn font-semibold rounded inline-flex items-center gap-2 mr-2"
onclick="$('#commands_dropdown').slideToggle('medium');" data-cy="kwlang-switch-btn">
<span class="fa-solid fa-language"></span>
{% if not g.latin and g.keyword_lang != "en" %}{{ current_language().sym }}{% else %}{{current_keyword_language().lang}}{% endif %}
<svg id="keyword-arrow" class="fill-current h-6 w-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
</svg>
Expand Down
Loading