Skip to content

Commit

Permalink
Fix root active locales
Browse files Browse the repository at this point in the history
  • Loading branch information
janbrasna committed Aug 28, 2024
1 parent d32bb17 commit bc2d790
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bedrock/base/templates/404-locale.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h1 class="c-simple-header-title">
<section class="c-block-list">
<ul>
{% for locale in available_locales if locale in languages %}
<li lang="{{ locale }}"><a href="/{{ locale }}{{ request.path_info }}" title="{{ 'Browse {0} in the {1} language'|f(request.path_info, languages[locale]["native"]) }}">{{ languages[locale]['native'] }}</a></li>
<li lang="{{ locale }}"><a href="/{{ locale }}{{ request.path_info }}" title="{{ 'Browse {0} in the {1} language'|f(request.path_info, languages[locale]["English"]) }}">{{ languages[locale]['native'] }}</a></li>
{% endfor %}
</ul>
</section>
Expand Down
4 changes: 3 additions & 1 deletion lib/l10n_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ def render(request, template, context=None, ftl_files=None, activation_files=Non
translations.update(ftl_active_locales(af))
translations = sorted(translations) # `sorted` returns a list.
elif l10n:
translations = l10n.active_locales
translations = l10n.active_locales if not is_root_path_with_no_language_clues(request) else l10n.active_home_locales
allowed = settings.PROD_LANGUAGES if not settings.DEV else settings.DEV_LANGUAGES
translations = set(translations).intersection(allowed)

# if `add_active_locales` is given then add it to the translations for the template
if "add_active_locales" in context:
Expand Down
5 changes: 5 additions & 0 deletions lib/l10n_utils/fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def active_locales(self):
# first resource is the one to check for activation
return get_active_locales(self.resource_ids[0])

@cached_property
def active_home_locales(self):
# use mozorg/home to check for activation
return get_active_locales("mozorg/home.ftl")

@cached_property
def percent_translated(self):
if not self._message_ids:
Expand Down

0 comments on commit bc2d790

Please sign in to comment.