Skip to content

Commit

Permalink
Fix multi-fallback language support in rebuild_page_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Dec 19, 2016
1 parent 4431072 commit c903cb1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions fluent_pages/management/commands/rebuild_page_tree.py
Expand Up @@ -101,7 +101,7 @@ def handle_noargs(self, **options):
)))

def _construct_url(self, language_code, child_id, parents, slugs, overrides):
fallback = appsettings.FLUENT_PAGES_LANGUAGES.get_fallback_language(language_code)
active_choices = appsettings.FLUENT_PAGES_LANGUAGES.get_active_choices(language_code)

breadcrumb = []
cur = child_id
Expand All @@ -119,9 +119,13 @@ def _construct_url(self, language_code, child_id, parents, slugs, overrides):
continue
except KeyError:
pass
try:
url_parts.append(slugs[language_code][id])
except KeyError:
url_parts.append(slugs[fallback][id])

# Add first one found, preferably the normal language, fallback otherwise.
for lang in active_choices:
try:
url_parts.append(slugs[lang][id])
break
except KeyError:
continue

return (u'/'.join(url_parts) + u'/').replace('//', '/')

0 comments on commit c903cb1

Please sign in to comment.