mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
[1.1.X] Fixed #12230 - Updated utils.translation.to_locale to support the special sr_Latn locale. Thanks to Janos Guljas.
Backport of r12056. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12251 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d1e7fdea3f
commit
3a417736bc
@ -40,6 +40,9 @@ def to_locale(language, to_lower=False):
|
|||||||
if to_lower:
|
if to_lower:
|
||||||
return language[:p].lower()+'_'+language[p+1:].lower()
|
return language[:p].lower()+'_'+language[p+1:].lower()
|
||||||
else:
|
else:
|
||||||
|
# Get correct locale for sr-latn
|
||||||
|
if len(language[p+1:]) > 2:
|
||||||
|
return language[:p].lower()+'_'+language[p+1].upper()+language[p+2:].lower()
|
||||||
return language[:p].lower()+'_'+language[p+1:].upper()
|
return language[:p].lower()+'_'+language[p+1:].upper()
|
||||||
else:
|
else:
|
||||||
return language.lower()
|
return language.lower()
|
||||||
|
@ -4,7 +4,7 @@ import misc
|
|||||||
regressions = ur"""
|
regressions = ur"""
|
||||||
Format string interpolation should work with *_lazy objects.
|
Format string interpolation should work with *_lazy objects.
|
||||||
|
|
||||||
>>> from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy
|
>>> from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy, to_locale
|
||||||
>>> s = ugettext_lazy('Add %(name)s')
|
>>> s = ugettext_lazy('Add %(name)s')
|
||||||
>>> d = {'name': 'Ringo'}
|
>>> d = {'name': 'Ringo'}
|
||||||
>>> s % d
|
>>> s % d
|
||||||
@ -17,6 +17,21 @@ u'Ringo hinzuf\xfcgen'
|
|||||||
u'Dodaj Ringo'
|
u'Dodaj Ringo'
|
||||||
>>> deactivate()
|
>>> deactivate()
|
||||||
|
|
||||||
|
Tests the to_locale function and the special case of Serbian Latin (refs #12230 and r11299)
|
||||||
|
|
||||||
|
>>> to_locale('en-us')
|
||||||
|
'en_US'
|
||||||
|
>>> to_locale('sr-lat')
|
||||||
|
'sr_Lat'
|
||||||
|
|
||||||
|
Test the to_language function
|
||||||
|
|
||||||
|
>>> from django.utils.translation.trans_real import to_language
|
||||||
|
>>> to_language('en_US')
|
||||||
|
'en-us'
|
||||||
|
>>> to_language('sr_Lat')
|
||||||
|
'sr-lat'
|
||||||
|
|
||||||
It should be possible to compare *_lazy objects.
|
It should be possible to compare *_lazy objects.
|
||||||
|
|
||||||
>>> s1 = ugettext_lazy('Add %(name)s')
|
>>> s1 = ugettext_lazy('Add %(name)s')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user