mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-03-17 05:40:26 +00:00
Fix issue #133: Support discovering locale directories like zh_Hans(xx_Xxxx)
This commit is contained in:
parent
20de6bf039
commit
5969b598d7
3 changed files with 43 additions and 3 deletions
|
|
@ -134,10 +134,10 @@ def find_pos(lang, project_apps=True, django_apps=False, third_party_apps=False)
|
|||
langs = [lang, ]
|
||||
if u'-' in lang:
|
||||
_l, _c = map(lambda x: x.lower(), lang.split(u'-', 1))
|
||||
langs += [u'%s_%s' % (_l, _c), u'%s_%s' % (_l, _c.upper()), ]
|
||||
langs += [u'%s_%s' % (_l, _c), u'%s_%s' % (_l, _c.upper()), u'%s_%s' % (_l, _c.capitalize()),]
|
||||
elif u'_' in lang:
|
||||
_l, _c = map(lambda x: x.lower(), lang.split(u'_', 1))
|
||||
langs += [u'%s-%s' % (_l, _c), u'%s-%s' % (_l, _c.upper()), ]
|
||||
langs += [u'%s-%s' % (_l, _c), u'%s-%s' % (_l, _c.upper()), u'%s_%s' % (_l, _c.capitalize()),]
|
||||
|
||||
paths = map(os.path.normpath, paths)
|
||||
paths = list(set(paths))
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ class RosettaTestCase(TestCase):
|
|||
settings.LANGUAGES = (
|
||||
('xx', 'dummy language'),
|
||||
('fr_FR.utf8', 'French (France), UTF8'),
|
||||
('bs-Cyrl-BA', u'Bosnian (Cyrillic) (Bosnia and Herzegovina)')
|
||||
('bs-Cyrl-BA', u'Bosnian (Cyrillic) (Bosnia and Herzegovina)'),
|
||||
('yy-Anot', u'Yet Another dummy language'),
|
||||
)
|
||||
|
||||
self.__session_engine = settings.SESSION_ENGINE
|
||||
|
|
@ -714,6 +715,11 @@ class RosettaTestCase(TestCase):
|
|||
r = self.client.get(reverse('rosetta-pick-file'))
|
||||
self.assertTrue(os.path.normpath('locale/bs-Cyrl-BA/LC_MESSAGES/django.po') in str(r.content))
|
||||
|
||||
def test_37_issue_133_complex_locales(self):
|
||||
r = self.client.get(reverse('rosetta-pick-file') + '?filter=all')
|
||||
r = self.client.get(reverse('rosetta-pick-file'))
|
||||
self.assertTrue(os.path.normpath('locale/yy_Anot/LC_MESSAGES/django.po') in str(r.content))
|
||||
|
||||
|
||||
# Stubbed access control function
|
||||
def no_access(user):
|
||||
|
|
|
|||
34
testproject/locale/yy_Anot/LC_MESSAGES/django.po
Normal file
34
testproject/locale/yy_Anot/LC_MESSAGES/django.po
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-09-14 02:28-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
||||
|
||||
#: templates/test.html:3
|
||||
msgid "Some text to translate"
|
||||
msgstr ""
|
||||
|
||||
#: templates/test.html:5
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
"one bottle of beer on the wall\n"
|
||||
msgid_plural ""
|
||||
"\n"
|
||||
"%(num_bottles)s bottles of beer on the wall\n"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
Loading…
Reference in a new issue