Merge commit '4067e069bd680d67aea10afbd841113f6a7f3fd3' into reflang

That's (I think), the last commit for v0.6.7 (versionning in this
project is hazy).
This commit is contained in:
Virgil Dupras 2013-01-29 15:47:27 -05:00
commit 1a13a890b6
14 changed files with 220 additions and 49 deletions

View file

@ -1,3 +1,8 @@
* Added a testproject to run tests
* Updated french translation. Thanks, @BertrandBordage
* Merged @sleepyjames' PR that fixes an error when pofile save path contains '.po' in the path
* Merged @rory's PR to correcty handle plural strings that have a leading/trailing newline (Issue #34)
Version 0.6.6
-------------
* Django 1.4 support (Issue #30, #33)

View file

@ -3,3 +3,4 @@ include LICENSE
recursive-include rosetta/locale *
recursive-include rosetta/tests *
recursive-include rosetta/templates *
prune testproject

View file

@ -20,9 +20,7 @@ Features
Requirements
************
Rosetta requires Django 1.2 or later.
Note that Rosetta is known to work with Django 1.1, but it is not supported.
Rosetta requires Django 1.3 or later (it should work with Django 1.1 and 1.2, but it is not supported.)
************
Installation

View file

@ -1,4 +1,4 @@
VERSION = (0, 6, 6)
VERSION = (0, 6, 7)
def get_version(svn=False, limit=3):

View file

@ -2,61 +2,77 @@
# 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.
#
#
msgid ""
msgstr ""
"Project-Id-Version: Rosetta\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-07-04 13:42+0200\n"
"POT-Creation-Date: 2012-04-05 15:09+0200\n"
"PO-Revision-Date: 2008-09-22 11:02\n"
"Last-Translator: Admin Admin <admin@admin.com>\n"
"Language-Team: French <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Translated-Using: django-rosetta 0.4.RC2\n"
"X-Translated-Using: django-rosetta 0.6.7\n"
#: templates/rosetta/languages.html:4 templates/rosetta/languages.html.py:6
msgid "Language selection"
msgstr "Sélection de la langue"
#: templates/rosetta/languages.html:6 templates/rosetta/pofile.html:18
#: templates/rosetta/languages.html:6 templates/rosetta/pofile.html:21
msgid "Home"
msgstr "Accueil"
#: templates/rosetta/languages.html:17
#: templates/rosetta/languages.html:11
msgid "Filter"
msgstr "Filtrer"
#: templates/rosetta/languages.html:12
msgid "Project"
msgstr "Projet"
#: templates/rosetta/languages.html:13
msgid "Third party"
msgstr "Tiers"
#: templates/rosetta/languages.html:15 templates/rosetta/pofile.html:38
msgid "All"
msgstr "Tous"
#: templates/rosetta/languages.html:28
msgid "Application"
msgstr "Application"
#: templates/rosetta/languages.html:18
#: templates/rosetta/languages.html:29
msgid "Progress"
msgstr "Progression"
#: templates/rosetta/languages.html:19
#: templates/rosetta/languages.html:30
msgid "Messages"
msgstr "Messages"
#: templates/rosetta/languages.html:20
#: templates/rosetta/languages.html:31
msgid "Translated"
msgstr "Traduits"
#: templates/rosetta/languages.html:21 templates/rosetta/pofile.html:57
#: templates/rosetta/languages.html:32 templates/rosetta/pofile.html:70
msgid "Fuzzy"
msgstr "Flous"
#: templates/rosetta/languages.html:22
#: templates/rosetta/languages.html:33
msgid "Obsolete"
msgstr "Obsolètes"
#: templates/rosetta/languages.html:23
#: templates/rosetta/languages.html:34
msgid "File"
msgstr "Fichier"
#: templates/rosetta/languages.html:44
#: templates/rosetta/languages.html:57
msgid "Nothing to translate!"
msgstr "Rien à Traduire!"
#: templates/rosetta/languages.html:45
#: templates/rosetta/languages.html:58
msgid ""
"You haven't specified any languages in your settings file, or haven't yet "
"generated a batch of translation catalogs."
@ -66,11 +82,12 @@ msgstr ""
"projet."
# python-format
#: templates/rosetta/languages.html:46
#: templates/rosetta/languages.html:59
#, python-format
msgid ""
"Please refer to <a href=\"%(i18n_doc_link)s\">Django's I18N documentation</"
"a> for a guide on how to set up internationalization for your project."
"Please refer to <a href=\"%(i18n_doc_link)s\">Django's I18N "
"documentation</a> for a guide on how to set up internationalization for your"
" project."
msgstr ""
"Veuillez vous référer à la <a href=\"%(i18n_doc_link)s\">documentation sur "
"l'internationalisation de Django</a> pour un guide sur comment activer et "
@ -84,88 +101,91 @@ msgstr "Choisir un autre fichier"
msgid "Download this catalog"
msgstr "Télécharger ce catalogue"
#: templates/rosetta/pofile.html:21
msgid "Progress: %(percent_translated)s%"
msgstr "Progression: %(percent_translated)s%"
#: templates/rosetta/pofile.html:24
#, python-format
msgid "Progress: %(percent_translated)s%%"
msgstr "Progression: %(percent_translated)s%%"
#: templates/rosetta/pofile.html:23
#: templates/rosetta/pofile.html:26
msgid "File is read-only: download the file when done editing!"
msgstr ""
"Fichier en seule lecture: télécharger le fichier à la fin de l'édition!"
#: templates/rosetta/pofile.html:24
#: templates/rosetta/pofile.html:27
msgid ""
"Some items in your last translation block couldn't be saved: this usually "
"happens when the catalog file changes on disk after you last loaded it."
msgstr "Certains parmi vos derniers éléments n'ont pas pu être sauvés: ceci "
"arrive généralement quand le catalogue de traductions à été modifié après qu'il ait "
"été chargé."
msgstr ""
"Certains parmi vos derniers éléments n'ont pas pu être sauvés: ceci arrive "
"généralement quand le catalogue de traductions à été modifié après qu'il ait"
" été chargé."
#: templates/rosetta/pofile.html:28
#: templates/rosetta/pofile.html:31
#, python-format
msgid "Translate into %(rosetta_i18n_lang_name)s"
msgstr "Traduire en %(rosetta_i18n_lang_name)s"
#: templates/rosetta/pofile.html:31
#: templates/rosetta/pofile.html:34
msgid "Display:"
msgstr "Afficher:"
#: templates/rosetta/pofile.html:32
#: templates/rosetta/pofile.html:35
msgid "Untranslated only"
msgstr "Non-traduits uniquement"
#: templates/rosetta/pofile.html:33
#: templates/rosetta/pofile.html:36
msgid "Translated only"
msgstr "Traduits uniquement"
#: templates/rosetta/pofile.html:34
#: templates/rosetta/pofile.html:37
msgid "Fuzzy only"
msgstr "Flous uniquement"
#: templates/rosetta/pofile.html:35
msgid "All"
msgstr "Tous"
#: templates/rosetta/pofile.html:42
#: templates/rosetta/pofile.html:45
msgid "Search"
msgstr "Recherche"
#: templates/rosetta/pofile.html:44
#: templates/rosetta/pofile.html:47
msgid "Go"
msgstr "Go"
#: templates/rosetta/pofile.html:54
#: templates/rosetta/pofile.html:67
msgid "Original"
msgstr "Original"
#: templates/rosetta/pofile.html:58
#: templates/rosetta/pofile.html:71
msgid "Occurrences(s)"
msgstr "Occurrences(s)"
#: templates/rosetta/pofile.html:82
#: templates/rosetta/pofile.html:85 templates/rosetta/pofile.html.py:88
#: templates/rosetta/pofile.html:103 templates/rosetta/pofile.html.py:106
msgid "Context hint"
msgstr "Indice contextuel"
#: templates/rosetta/pofile.html:113
msgid "suggest"
msgstr "suggérer"
#: templates/rosetta/pofile.html:93
#: templates/rosetta/pofile.html:124
#, python-format
msgid "%(more_count)s more"
msgid_plural "%(more_count)s more"
msgstr[0] "%(more_count)s de plus"
msgstr[1] "%(more_count)s de plus"
#: templates/rosetta/pofile.html:105
#: templates/rosetta/pofile.html:136
msgid "Save and translate next block"
msgstr "Sauver et traduire le prochain bloc"
#: templates/rosetta/pofile.html:109
#: templates/rosetta/pofile.html:140
msgid "Skip to page:"
msgstr "Passer à la page:"
#: templates/rosetta/pofile.html:122
#: templates/rosetta/pofile.html:153
msgid "Displaying:"
msgstr "Affichés:"
#: templates/rosetta/pofile.html:124
#: templates/rosetta/pofile.html:157
#, python-format
msgid "%(hits)s/%(message_number)s message"
msgid_plural "%(hits)s/%(message_number)s messages"

View file

@ -457,3 +457,26 @@ class RosettaTestCase(TestCase):
self.assertTrue('felis eu pede mollis pretium."' in pofile_content)
shutil.move(self.dest_file + '.orig', self.dest_file)
def test_18_Test_Issue_gh34(self):
shutil.copy(self.dest_file, self.dest_file + '.orig')
shutil.copy(os.path.normpath(os.path.join(self.curdir, './django.po.issue34gh.template')), self.dest_file)
self.client.get(reverse('rosetta-pick-file') + '?filter=third-party')
r = self.client.get(reverse('rosetta-language-selection', args=('xx', 0, ), kwargs=dict()))
r = self.client.get(reverse('rosetta-home'))
self.assertTrue('m_ff7060c1a9aae9c42af4d54ac8551f67_1' in r.content)
self.assertTrue('m_ff7060c1a9aae9c42af4d54ac8551f67_0' in r.content)
self.assertTrue('m_09f7e02f1290be211da707a266f153b3' in r.content)
# post a translation, it should have properly wrapped lines
r = self.client.post(reverse('rosetta-home'), dict(
m_ff7060c1a9aae9c42af4d54ac8551f67_0='Foo %s',
m_ff7060c1a9aae9c42af4d54ac8551f67_1='Bar %s',
m_09f7e02f1290be211da707a266f153b3='Salut', _next='_next'))
pofile_content = open(self.dest_file, 'r').read()
self.assertTrue('msgstr "Salut\\n"' in pofile_content)
self.assertTrue('msgstr[0] ""\n"\\n"\n"Foo %s\\n"' in pofile_content)
self.assertTrue('msgstr[1] ""\n"\\n"\n"Bar %s\\n"' in pofile_content)
shutil.move(self.dest_file + '.orig', self.dest_file)

View file

@ -0,0 +1,29 @@
# 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.
#
msgid ""
msgstr ""
"Project-Id-Version: Rosetta\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-10-21 12:21+0200\n"
"PO-Revision-Date: 2008-09-22 11:02\n"
"Last-Translator: Admin Admin <admin@admin.com>\n"
"Language-Team: French <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Translated-Using: django-rosetta 0.4.RC2\n"
msgid ""
"\n"
" %s customer hidden\n"
msgid_plural ""
"\n"
" %s customers hidden\n"
msgstr[0] ""
msgstr[1] ""
msgid "Hello\n"
msgstr ""

View file

@ -45,6 +45,7 @@ def home(request):
out_ = out_.rstrip()
return out_
version = rosetta.get_version(True)
if 'rosetta_i18n_fn' in request.session:
rosetta_i18n_fn = request.session.get('rosetta_i18n_fn')
@ -101,7 +102,8 @@ def home(request):
if entry:
old_msgstr = entry.msgstr
if plural_id is not None:
plural_string = fix_nls(entry.msgstr_plural[plural_id], value)
#plural_string = fix_nls(entry.msgstr_plural[plural_id], value)
plural_string = fix_nls(entry.msgid_plural, value)
entry.msgstr_plural[plural_id] = plural_string
else:
entry.msgstr = fix_nls(entry.msgid, value)
@ -140,9 +142,12 @@ def home(request):
rosetta_i18n_pofile.metadata['PO-Revision-Date'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M%z')
except UnicodeDecodeError:
pass
try:
rosetta_i18n_pofile.save()
rosetta_i18n_pofile.save_as_mofile(rosetta_i18n_fn.replace('.po', '.mo'))
po_filepath, ext = os.path.splitext(rosetta_i18n_fn)
save_as_mo_filepath = po_filepath + '.mo'
rosetta_i18n_pofile.save_as_mofile(save_as_mo_filepath)
post_save.send(sender=None, language_code=rosetta_i18n_lang_code, request=request)
# Try auto-reloading via the WSGI daemon mode reload mechanism

5
runtests.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
cd testproject
python manage.py test rosetta
cd ..

0
testproject/__init__.py Normal file
View file

16
testproject/manage.py Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env python
from django.core.management import execute_manager
import sys
import os
try:
import settings # Assumed to be in the same directory.
except ImportError:
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, BASEDIR)
if __name__ == "__main__":
execute_manager(settings)

52
testproject/settings.py Normal file
View file

@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
import django
import os
import sys
SITE_ID = 1
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
PYTHON_VERSION = '%s.%s' % sys.version_info[:2]
DJANGO_VERSION = django.get_version()
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_PATH, 'rosetta.db')
}
}
TEST_DATABASE_CHARSET = "utf8"
TEST_DATABASE_COLLATION = "utf8_general_ci"
DATABASE_SUPPORTS_TRANSACTIONS = True
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'rosetta',
]
LANGUAGE_CODE = "en"
LANGUAGES = (
('en', 'English'),
('ja', u'日本語'),
('xx', u'XXXXX'),
)
SOUTH_TESTS_MIGRATE = False
FIXTURE_DIRS = (
os.path.join(PROJECT_PATH, 'fixtures'),
)
ROOT_URLCONF = 'testproject.urls'
DEBUG = True
TEMPLATE_DEBUG = True

17
testproject/urls.py Normal file
View file

@ -0,0 +1,17 @@
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'testproject.views.home', name='home'),
# url(r'^testproject/', include('testproject.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# url(r'^admin/', include(admin.site.urls)),
)