mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-05-22 03:11:54 +00:00
Added support for composite locales
This commit is contained in:
parent
dc312441f9
commit
83b65717f2
11 changed files with 57 additions and 28 deletions
1
CHANGES
1
CHANGES
|
|
@ -10,6 +10,7 @@ Version 0.7.7 (unreleased)
|
|||
* Include the testproject in the sdist tarball to allow Debian to run tests during installation (Issue #137, thanks @fladi)
|
||||
* Display an explicit error message to the enduser when saving the POfile fails for some reason (Issue #135, thanks @pgcd)
|
||||
* Added support for PEP 3101 string formatting (PR #140, thanks @adamjforster)
|
||||
* Added support for composite locales, e.g. 'bs-Cyrl-BA' (Issue #142, thanks @felarov)
|
||||
|
||||
|
||||
Version 0.7.6
|
||||
|
|
|
|||
|
|
@ -143,10 +143,10 @@ def find_pos(lang, project_apps=True, django_apps=False, third_party_apps=False)
|
|||
ret = set()
|
||||
langs = [lang, ]
|
||||
if u'-' in lang:
|
||||
_l, _c = map(lambda x: x.lower(), lang.split(u'-'))
|
||||
_l, _c = map(lambda x: x.lower(), lang.split(u'-', 1))
|
||||
langs += [u'%s_%s' % (_l, _c), u'%s_%s' % (_l, _c.upper()), ]
|
||||
elif u'_' in lang:
|
||||
_l, _c = map(lambda x: x.lower(), lang.split(u'_'))
|
||||
_l, _c = map(lambda x: x.lower(), lang.split(u'_', 1))
|
||||
langs += [u'%s-%s' % (_l, _c), u'%s-%s' % (_l, _c.upper()), ]
|
||||
|
||||
paths = map(os.path.normpath, paths)
|
||||
|
|
|
|||
|
|
@ -7,24 +7,13 @@ from django.core.cache import cache
|
|||
from django.template.defaultfilters import floatformat
|
||||
from django.test import TestCase
|
||||
from django.test.client import Client
|
||||
from django.dispatch import receiver
|
||||
from rosetta.conf import settings as rosetta_settings
|
||||
from rosetta.signals import entry_changed, post_save
|
||||
import os
|
||||
import shutil
|
||||
import six
|
||||
import django
|
||||
import json
|
||||
|
||||
|
||||
try:
|
||||
from django.dispatch import receiver
|
||||
except ImportError:
|
||||
# We might be in django < 1.3, so backport this function
|
||||
def receiver(signal, **kwargs):
|
||||
def _decorator(func):
|
||||
signal.connect(func, **kwargs)
|
||||
return func
|
||||
return _decorator
|
||||
|
||||
|
||||
class RosettaTestCase(TestCase):
|
||||
|
|
@ -54,7 +43,11 @@ class RosettaTestCase(TestCase):
|
|||
self.client2.login(username='test_admin2', password='test_password')
|
||||
|
||||
self.__old_settings_languages = settings.LANGUAGES
|
||||
settings.LANGUAGES = (('xx', 'dummy language'), ('fr_FR.utf8', 'French (France), UTF8'))
|
||||
settings.LANGUAGES = (
|
||||
('xx', 'dummy language'),
|
||||
('fr_FR.utf8', 'French (France), UTF8'),
|
||||
('bs-Cyrl-BA', u'Bosnian (Cyrillic) (Bosnia and Herzegovina)')
|
||||
)
|
||||
|
||||
self.__session_engine = settings.SESSION_ENGINE
|
||||
self.__storage_class = rosetta_settings.STORAGE_CLASS
|
||||
|
|
@ -709,6 +702,11 @@ class RosettaTestCase(TestCase):
|
|||
# cleanup
|
||||
os.chmod(self.dest_file, 420) # 0644
|
||||
|
||||
def test_36_issue_142_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/bs-Cyrl-BA/LC_MESSAGES/django.po') in str(r.content))
|
||||
|
||||
|
||||
# Stubbed access control function
|
||||
def no_access(user):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ except ImportError:
|
|||
from django.conf.urls.defaults import patterns, include, url
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^rosetta/',include('rosetta.urls')),
|
||||
url(r'^admin/$','rosetta.tests.views.dummy', name='dummy-login')
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^rosetta/', include('rosetta.urls')),
|
||||
url(r'^admin/$', 'rosetta.tests.views.dummy', name='dummy-login')
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
def dummy(request):
|
||||
pass
|
||||
|
||||
|
|
|
|||
34
testproject/locale/bs-Cyrl-BA/LC_MESSAGES/django.po
Normal file
34
testproject/locale/bs-Cyrl-BA/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] ""
|
||||
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-04-30 14:37+0200\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"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-04-30 14:37+0200\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"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Rosetta\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-04-30 14:37+0200\n"
|
||||
"POT-Creation-Date: 2015-09-14 02:28-0500\n"
|
||||
"PO-Revision-Date: 2012-05-27 14:59\n"
|
||||
"Last-Translator: <admin@admin.com>\n"
|
||||
"Language-Team: French <LL@li.org>\n"
|
||||
|
|
@ -35,12 +35,6 @@ msgstr[0] ""
|
|||
msgstr[1] ""
|
||||
msgstr[2] ""
|
||||
|
||||
#. This is a contextual comment
|
||||
#: templates/test.html:3
|
||||
msgid "Some text to translate"
|
||||
msgstr ""
|
||||
|
||||
|
||||
#~ msgid ""
|
||||
#~ "0_81EhfRiLPoxAH5j3f1D2P33S_-"
|
||||
#~ "Fe_7Mn_R_t9V8Bysr01xWAgvVEyyA190oYYTnzJCBucLBWKiqaAIjWAvQ3ZfrbCkDRe02iESoGhHEIBmmDI49SY6cQQk0AxGoB-"
|
||||
|
|
|
|||
|
|
@ -60,11 +60,13 @@ MIDDLEWARE_CLASSES = (
|
|||
)
|
||||
|
||||
LANGUAGES = (
|
||||
('bs-Cyrl-BA', u'Bosnian (Cyrillic) (Bosnia and Herzegovina)'),
|
||||
('ja', u'日本語'),
|
||||
('xx', u'XXXXX'),
|
||||
('fr', u'French'),
|
||||
('fr_FR.utf8', u'French (France), UTF8'),
|
||||
)
|
||||
|
||||
LOCALE_PATHS = [
|
||||
os.path.join(PROJECT_PATH, 'locale'),
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue