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

Fix missing languages in stats from product_details. #10595

Merged
merged 2 commits into from
Feb 5, 2019
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
6 changes: 4 additions & 2 deletions src/olympia/browse/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ def check(locale, english, native):
actual = locale_display_name(locale)
assert actual == (english, native)

check('el', 'Greek', u'Ελληνικά')
check('el-XX', 'Greek', u'Ελληνικά')
check('el', u'Greek', u'Ελληνικά')
check('el-XX', u'Greek', u'Ελληνικά')
check('wo', u'Wolof', u'Wolof')
check('es-MX', u'Spanish', u'Espa\xf1ol')
pytest.raises(KeyError, check, 'fake-lang', '', '')


Expand Down
8 changes: 4 additions & 4 deletions src/olympia/browse/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from olympia.amo.models import manual_order
from olympia.amo.urlresolvers import reverse
from olympia.amo.utils import render
from olympia.core.languages import LANGUAGE_MAPPING
from olympia.core.languages import ALL_LANGUAGES


PAGINATE_PERSONAS_BY = 30
Expand All @@ -34,8 +34,8 @@ def locale_display_name(locale):
if not locale:
raise KeyError

if locale.lower() in LANGUAGE_MAPPING:
v = LANGUAGE_MAPPING[locale.lower()]
if locale.lower() in ALL_LANGUAGES:
v = ALL_LANGUAGES[locale.lower()]
return v['english'], v['native']
else:
# Take out the regional portion and try again.
Expand Down Expand Up @@ -92,7 +92,7 @@ def _get_locales(addons):
english, native = locale_display_name(locale)
# Add the locale as a differentiator if we had to strip the
# regional portion.
if locale not in LANGUAGE_MAPPING:
if locale not in ALL_LANGUAGES:
native = '%s (%s)' % (native, locale)
addon.locale_display, addon.locale_native = english, native
except KeyError:
Expand Down
Loading