Merge commit '329e8c693bc90b667f6f09235eec728dffc62f87' into reflang.

That commit if v0.6.6.
This commit is contained in:
Virgil Dupras 2013-01-29 15:41:17 -05:00
commit 8f8429d27d
9 changed files with 70 additions and 66 deletions

View file

@ -1,3 +1,8 @@
Version 0.6.6
-------------
* Django 1.4 support (Issue #30, #33)
* Better handling of translation callbacks on Bing's translation API and support of composite locales (Issue #26)
Version 0.6.5
-------------
* Updated polib to 0.7.0

View file

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

View file

@ -31,28 +31,24 @@ def find_pos(lang, project_apps=True, django_apps=False, third_party_apps=False)
django_paths = cache.get('rosetta_django_paths')
if django_paths is None:
django_paths = []
for root,dirnames,filename in os.walk(os.path.abspath(os.path.dirname(django.__file__))):
for root, dirnames, filename in os.walk(os.path.abspath(os.path.dirname(django.__file__))):
if 'locale' in dirnames:
django_paths.append(os.path.join(root , 'locale'))
django_paths.append(os.path.join(root, 'locale'))
continue
cache.set('rosetta_django_paths', django_paths, 60*60)
cache.set('rosetta_django_paths', django_paths, 60 * 60)
paths = paths + django_paths
# settings
# settings
for localepath in settings.LOCALE_PATHS:
if os.path.isdir(localepath):
paths.append(localepath)
# project/app/locale
for appname in settings.INSTALLED_APPS:
if rosetta_settings.EXCLUDED_APPLICATIONS and appname in rosetta_settings.EXCLUDED_APPLICATIONS:
continue
p = appname.rfind('.')
if p >= 0:
app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:])
app = getattr(__import__(appname[:p], {}, {}, [appname[p + 1:]]), appname[p + 1:])
else:
app = __import__(appname, {}, {}, [])

View file

@ -32,4 +32,5 @@ div.module {margin-bottom: 20px;}
.checkall {cursor:pointer}
#toolbar { height:20px}
#toolbar #translate-all { float:right}
#toolbar form { float:left; }
#toolbar form { float:left; }
#changelist table thead th { padding: 2px 5px; }

View file

@ -1,56 +1,48 @@
{% load rosetta %}
google.setOnLoadCallback(function() {
$('.location a').show().toggle(function() {
$('.hide', $(this).parent()).show();
}, function() {
$('.hide', $(this).parent()).hide();
});
{% if ENABLE_TRANSLATION_SUGGESTIONS and BING_APP_ID %}
$('a.suggest').click(function() {
var a = $(this),
str = a.html(),
orig = $('.original .message', a.parents('tr')).html(),
trans=$('textarea',a.parent()),
sourceLang = '{{MESSAGES_SOURCE_LANGUAGE_CODE}}',
destLang = '{{rosetta_i18n_lang_code|slice:":2"}}',
app_id = '{{BING_APP_ID}}';
orig = unescape(orig).replace(/<br\s?\/?>/g,'\n').replace(/<code>/g,'').replace(/<\/code>/g,'').replace(/&gt;/g,'>').replace(/&lt;/g,'<');
$('a.suggest').click(function(e){
e.preventDefault();
var a = $(this);
var str = a.html();
var orig = $('.original .message', a.parents('tr')).html();
var trans=$('textarea',a.parent());
var sourceLang = '{{ MESSAGES_SOURCE_LANGUAGE_CODE }}';
var destLang = '{{ rosetta_i18n_lang_code }}';
var app_id = '{{ BING_APP_ID }}';
var apiUrl = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate";
orig = unescape(orig).replace(/<br\s?\/?>/g,'\n').replace(/<code>/,'').replace(/<\/code>/g,'').replace(/&gt;/g,'>').replace(/&lt;/g,'<');
a.attr('class','suggesting').html('...');
window.onTranslationComplete = function(resp) {
trans.val(unescape(resp).replace(/&#39;/g,'\'').replace(/&quot;/g,'"').replace(/%\s+(\([^\)]+\))\s*s/g,' %$1s '));
a.hide();
};
var s = document.createElement("script");
s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=onTranslationComplete&appId="+app_id +"&from=" + sourceLang + "&to=" + destLang + "&text=" + orig;
document.getElementsByTagName("head")[0].appendChild(s);
/*
google.language.translate(orig, , function(result) {
if (!result.error) {
trans.val(unescape(result.translation).replace(/&#39;/g,'\'').replace(/&quot;/g,'"').replace(/%\s+(\([^\)]+\))\s*s/g,' %$1s '));
a.hide();
} else {
a.hide().before($('<span class="alert">'+result.error.message+'</span>'));
}
});
*/
return false;
window.onTranslationError = function(response){
a.text(response);
};
var apiData = {
onerror: 'onTranslationError',
appid: app_id,
from: sourceLang,
to: destLang,
oncomplete: "onTranslationComplete",
text: orig
};
$.ajax({
url: apiUrl,
data: apiData,
dataType: 'jsonp'});
});
$('#translate-all').submit(function() {
$('a.suggest').click();
return false;
});
$('.checkall').click(function(){
$('td.c input').attr('checked', '');
$('td.c input').attr('value', '0');
});
{% endif %}
$('td.plural').each(function(i) {
var td = $(this), trY = parseInt(td.closest('tr').offset().top);
$('textarea', $(this).closest('tr')).each(function(j) {

View file

@ -49,7 +49,7 @@
<form id="changelist-search" action="" method="post">
<div><!-- DIV needed for valid HTML -->
{% rosetta_csrf_token %}
<label for="searchbar"><img src="{{ADMIN_MEDIA_PREFIX}}img/admin/icon_searchbox.png" alt="{% trans "Search" %}" /></label>
<label for="searchbar"><img src="{{ADMIN_IMAGE_DIR}}/icon_searchbox.png" alt="{% trans "Search" %}" /></label>
<input type="text" size="40" name="query" value="{% if query %}{{query}}{% endif %}" id="searchbar" tabindex="0" />
<input type="submit" name="search" value="{% trans "Go" %}" />
</div>
@ -70,7 +70,7 @@
<thead>
<tr>
{% rosetta_csrf_token %}
<th>{% trans "Original" %}</th>
<th><div class="text">{% trans "Original" %}</div></th>
{% if main_language %}<th>{{ main_language }}</th>{% endif %}
<th>{{ rosetta_i18n_lang_name }}</th>
<th class="c"><span class="checkall">[-]</span> {% trans "Fuzzy" %}</th>

View file

@ -4,6 +4,7 @@ from django.utils.html import escape
import re
from django.template import Node
from django.utils.encoding import smart_str, smart_unicode
from django.template.defaultfilters import stringfilter
register = template.Library()
rx = re.compile(r'(%(\([^\s\)]*\))?[sd])')
@ -27,7 +28,6 @@ def minus(a,b):
except:
return 0
minus=register.filter(minus)
def gt(a,b):
try:

View file

@ -7,7 +7,9 @@ from django.test import TestCase
from django.test.client import Client
from rosetta.conf import settings as rosetta_settings
from rosetta.signals import entry_changed, post_save
import os, shutil, django
import os
import shutil
import django
try:
@ -20,16 +22,15 @@ except ImportError:
return func
return _decorator
class RosettaTestCase(TestCase):
urls = 'rosetta.tests.urls'
def __init__(self, *args,**kwargs):
super(RosettaTestCase,self).__init__(*args,**kwargs)
def __init__(self, *args, **kwargs):
super(RosettaTestCase, self).__init__(*args, **kwargs)
self.curdir = os.path.dirname(__file__)
self.dest_file = os.path.normpath(os.path.join(self.curdir, '../locale/xx/LC_MESSAGES/django.po'))
self.django_version_major, self.django_version_minor = django.VERSION[0],django.VERSION[1]
self.django_version_major, self.django_version_minor = django.VERSION[0], django.VERSION[1]
def setUp(self):
user = User.objects.create_user('test_admin', 'test@test.com', 'test_password')
@ -282,10 +283,10 @@ class RosettaTestCase(TestCase):
# reset the original file
shutil.move(self.dest_file+'.orig', self.dest_file)
def test_11_issue_80_tab_indexes(self):
self.client.get(reverse('rosetta-pick-file')+'?filter=third-party')
r = self.client.get(reverse('rosetta-language-selection', args=('xx',0,), kwargs=dict() ))
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('tabindex="3"' in r.content)

View file

@ -232,7 +232,12 @@ def home(request):
page_range = pagination_range(1, paginator.num_pages, page)
else:
page_range = range(1, 1 + paginator.num_pages)
ADMIN_MEDIA_PREFIX = settings.ADMIN_MEDIA_PREFIX
try:
ADMIN_MEDIA_PREFIX = settings.ADMIN_MEDIA_PREFIX
ADMIN_IMAGE_DIR = ADMIN_MEDIA_PREFIX + 'img/admin/'
except AttributeError:
ADMIN_MEDIA_PREFIX = settings.STATIC_URL + 'admin/'
ADMIN_IMAGE_DIR = ADMIN_MEDIA_PREFIX + 'img/'
ENABLE_TRANSLATION_SUGGESTIONS = rosetta_settings.BING_APP_ID and rosetta_settings.ENABLE_TRANSLATION_SUGGESTIONS
BING_APP_ID = rosetta_settings.BING_APP_ID
MESSAGES_SOURCE_LANGUAGE_NAME = rosetta_settings.MESSAGES_SOURCE_LANGUAGE_NAME
@ -317,7 +322,11 @@ def list_languages(request):
[(get_app_name(l), os.path.realpath(l), pofile(l)) for l in pos],
)
)
ADMIN_MEDIA_PREFIX = settings.ADMIN_MEDIA_PREFIX
try:
ADMIN_MEDIA_PREFIX = settings.ADMIN_MEDIA_PREFIX
except AttributeError:
ADMIN_MEDIA_PREFIX = settings.STATIC_URL + 'admin/'
version = rosetta.get_version(True)
return render_to_response('rosetta/languages.html', locals(), context_instance=RequestContext(request))
list_languages = never_cache(list_languages)