Opened 7 years ago

Closed 7 years ago

#28755 closed Bug (fixed)

django.utils.translation.check_for_language doesn't check in the app folders

Reported by: Dorian Amouroux Owned by: ChillarAnand
Component: Internationalization Version: 1.11
Severity: Normal Keywords:
Cc: ChillarAnand Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using the set_language view to set the language for the user, it doesn't work if the language file is not in settings.LOCALE_PATHS nor in django/conf/locale/.

Indeed set_language (https://github.com/django/django/blob/stable/1.11.x/django/views/i18n.py#L50) calls the function check_for_language. check_for_language will check if the language in parameter exists in the gettext catalog. However, check_for_language calls the function all_locale_paths (https://github.com/django/django/blob/stable/1.11.x/django/utils/translation/trans_real.py#L411) which doesn't contains the path of the apps.

I create a language that doesn't exist in the Django default language, I can't switch to this language because it cannot be found, it only exists in the locale directory inside my apps.

Change History (9)

comment:1 by Claude Paroz, 7 years ago

Easy pickings: unset
Has patch: unset
Triage Stage: UnreviewedAccepted

comment:2 by ChillarAnand, 7 years ago

Owner: changed from nobody to ChillarAnand
Status: newassigned

comment:3 by ChillarAnand, 7 years ago

Cc: ChillarAnand added
Has patch: set

comment:4 by Claude Paroz, 7 years ago

Needs tests: set

comment:5 by ChillarAnand, 7 years ago

Needs tests: unset

Thanks Claude Paroz. Added a test case.

comment:8 by Tim Graham, 7 years ago

Patch needs improvement: set

Left a comment for improvement about putting the test in a better location.

comment:9 by ChillarAnand, 7 years ago

Patch needs improvement: unset

Added test case for check_for_language.

comment:10 by Carlton Gibson, 7 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In e8e0cfa:

Fixed #28755 -- Made check_for_language() include apps' locale directories.

Note: See TracTickets for help on using tickets.
Back to Top