diff --git a/.gitignore b/.gitignore index c093944..7c640e4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ dist .svnignore .svnexternals build -rosetta/locale/xx/LC_MESSAGES/*.mo \ No newline at end of file +rosetta/locale/xx/LC_MESSAGES/*.mo +/.settings +/.project diff --git a/CHANGES b/CHANGES index b15d6f9..7ab3b2b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +* Support timezones on the last modified PO header. Thanks @jmoiron (Issue #43) +* Actually move to the next block when submitting a lot of translations (Issue #13) +* Add msgctxt to the entry hash to differentiate entries with context. Thanks @metalpriest (Issue #39) + Version 0.6.8 ------------- * Switched to a pluggable storage backend model to increase compatibility with Django 1.4. Cache and Session-based storages are provided. diff --git a/README.rst b/README.rst index be394c1..304ccf9 100644 --- a/README.rst +++ b/README.rst @@ -20,7 +20,7 @@ Features Requirements ************ -Rosetta requires Django 1.3 or later (it should work with Django 1.1 and 1.2, but it is not supported.) +Rosetta requires Django 1.3 or later ************ Installation diff --git a/rosetta/__init__.py b/rosetta/__init__.py index 664a7c7..7655aad 100644 --- a/rosetta/__init__.py +++ b/rosetta/__init__.py @@ -1,4 +1,4 @@ -VERSION = (0, 6, 8) +VERSION = (0, 7, 0) def get_version(svn=False, limit=3): diff --git a/rosetta/poutil.py b/rosetta/poutil.py index dc1483b..5e72a0b 100644 --- a/rosetta/poutil.py +++ b/rosetta/poutil.py @@ -3,6 +3,12 @@ import django from django.conf import settings from rosetta.conf import settings as rosetta_settings from django.core.cache import cache +from datetime import datetime +try: + from django.utils import timezone +except: + timezone = None + try: set @@ -10,6 +16,22 @@ except NameError: from sets import Set as set # Python 2.3 fallback +def timestamp_with_timezone(dt=None): + """ + Return a timestamp with a timezone for the configured locale. If all else + fails, consider localtime to be UTC. + """ + dt = dt or datetime.now() + if timezone is None: + return dt.strftime('%Y-%m-%d %H:%M%z') + if not dt.tzinfo: + tz = timezone.get_current_timezone() + if not tz: + tz = timezone.utc + dt = dt.replace(tzinfo=timezone.get_current_timezone()) + return dt.strftime("%Y-%m-%d %H:%M%z") + + def find_pos(lang, project_apps=True, django_apps=False, third_party_apps=False): """ scans a couple possible repositories of gettext catalogs for the given diff --git a/rosetta/storage.py b/rosetta/storage.py index 3e52443..75e6dd0 100644 --- a/rosetta/storage.py +++ b/rosetta/storage.py @@ -1,5 +1,7 @@ from django.core.cache import cache +from django.conf import settings from django.utils import importlib +from django.core.exceptions import ImproperlyConfigured import hashlib import time @@ -56,12 +58,28 @@ class CacheRosettaStorage(BaseRosettaStorage): # so we need to per-user key prefix, which we store in the session def __init__(self, request): super(CacheRosettaStorage, self).__init__(request) + if 'rosetta_cache_storage_key_prefix' in self.request.session: self._key_prefix = self.request.session['rosetta_cache_storage_key_prefix'] else: self._key_prefix = hashlib.new('sha1', str(time.time())).hexdigest() self.request.session['rosetta_cache_storage_key_prefix'] = self._key_prefix + if self.request.session['rosetta_cache_storage_key_prefix'] != self._key_prefix: + raise ImproperlyConfigured("You can't use the CacheRosettaStorage because your Django Session storage doesn't seem to be working. The CacheRosettaStorage relies on the Django Session storage to avoid conflicts.") + + # Make sure we're not using DummyCache + if 'dummycache' in settings.CACHES['default']['BACKEND'].lower(): + raise ImproperlyConfigured("You can't use the CacheRosettaStorage if your cache isn't correctly set up (you are use the DummyCache cache backend).") + + # Make sure the actually actually works + try: + self.set('rosetta_cache_test', 'rosetta') + if not self.get('rosetta_cache_test') == 'rosetta': + raise ImproperlyConfigured("You can't use the CacheRosettaStorage if your cache isn't correctly set up, please double check your Django DATABASES setting and that the cache server is responding.") + finally: + self.delete('rosetta_cache_test') + def get(self, key, default=None): #print ('get', self._key_prefix + key) return cache.get(self._key_prefix + key, default) diff --git a/rosetta/templates/rosetta/base.html b/rosetta/templates/rosetta/base.html index 19fe7a0..e3949df 100644 --- a/rosetta/templates/rosetta/base.html +++ b/rosetta/templates/rosetta/base.html @@ -1,16 +1,16 @@ - +{% load url from future %} {% block pagetitle %}Rosetta{% endblock %} - - + + - + - +