#4389 closed (fixed)
BIDI language detection not smart enough
Reported by: | Ahmad Alhashemi | Owned by: | Jannis Leidel |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Keywords: | bidi rtl sprintdec01 | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
one of my projects, I'm using a LANGUAGE_CODE of 'ar-kw' (Arabic-Kuwait). We already have an Arabic translation (ar) and it is being appropriately used. The problem is that my language code is not being detected as a right to left language. It has to be exactly 'ar' or it will not be detected.
Maybe we can bring some of the smartness of gettext into detecting the direction of text too?
There is a function in gettext called _expand_lang. It takes the locale as a single argument and returns a list of possible names for this locale, so that ar_KW will return a list containing ar_KW, ar and other locales.
Attachments (2)
Change History (13)
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 17 years ago
Owner: | changed from | to
---|
by , 17 years ago
comment:3 by , 17 years ago
Has patch: | set |
---|
comment:4 by , 17 years ago
Keywords: | sprintdec01 added |
---|
comment:5 by , 16 years ago
milestone: | → 1.0 |
---|---|
Status: | new → assigned |
Version: | 0.96 → SVN |
comment:6 by , 16 years ago
Changing django.utils.translation.get_language_bidi
so that it looks to see if xx
is in settings.LANGUAGES_BIDI
for a language xx-yy
(or xx
) seems like a nicer way to do this.
by , 16 years ago
Attachment: | get_language_bidi.diff added |
---|
Use only first part of language name (i.e., xx
for a language xx-yy
) for BiDi detection.
comment:7 by , 16 years ago
I don't see why this is nicer to not use a upstream function that does exactly that.
comment:8 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
gettext._expand_lang
expands a locale to a list of locales. That's not doing what is needed here. Besides, you're checking to see if any of those locales is listed in settings.LANGUAGES_BIDI
, which contains languages. The reason this works is more or less accident.
All that's needed is to check if xx
is in settings.LANGUAGES_BIDI
for some language xx-yy
. So that's what the patch does.
(You could extract the base_lang
function from translation
and get_language_bidi
to be more DRY, but I'll leave that to a committer.)
comment:10 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Added proposed support for _expand_lang