Skip to content

Commit

Permalink
💻 Language switcher text (#5309)
Browse files Browse the repository at this point in the history
Fixes #4835 

[Babel](https://www.unicode.org/cldr/charts/44/supplemental/territory_language_information.html) only lists language codes in Latin alphabet. I did some searching and I think it would be quite difficult to find the non Latin language codes. So for the non Latin languages, I thought the best solution would be to just state the _non Latin language_ in the switcher instead of the _non Latin language code._ 

**How to test**
1. Select a non latin language in your profile
2. Go to Hedy
3. Check if there is a language in the switcher (and it's not None)
4. Switch between English and the (non Latin) language

https://github.com/hedyorg/hedy/assets/48122190/73adcb1c-fefb-42f3-958d-3876dbf6eb7b
  • Loading branch information
Annelein authored Apr 1, 2024
1 parent 0b0d7ce commit 59f6474
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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
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

0 comments on commit 59f6474

Please sign in to comment.