Fixes the translation callback not being called and allow for suggestions on "zh-tw" and "zh-cn".

This commit is contained in:
Kit Sunde 2012-02-25 05:21:45 +08:00
parent 9fbf953216
commit b34d24915b
2 changed files with 6 additions and 4 deletions

View file

@ -1,3 +1,5 @@
{% load rosetta %}
google.setOnLoadCallback(function() {
$('.location a').show().toggle(function() {
$('.hide', $(this).parent()).show();
@ -13,7 +15,7 @@ google.setOnLoadCallback(function() {
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|slice:":2" }}';
var destLang = '{{ rosetta_i18n_lang_code }}';
var app_id = '{{ BING_APP_ID }}';
var apiUrl = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate";
@ -31,13 +33,13 @@ google.setOnLoadCallback(function() {
appid: app_id,
from: sourceLang,
to: destLang,
oncomplete: "onTranslationComplete",
text: orig
};
$.ajax({
url: apiUrl,
data: apiData,
dataType: 'jsonp',
jsonpCallback: 'onTranslationComplete'});
dataType: 'jsonp'});
});
{% endif %}

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: