alejandro-zapeta / django-rosetta

Automatically exported from code.google.com/p/django-rosetta
MIT License
0 stars 0 forks source link

Sublanguages & invalid translation language pair #112

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
With sublanguages (e.g. fr-be), the suggest link produce an error "invalid 
translation language pair".
The following patch fix that -- not sure it's the best way, though.

--- rosetta.js  2011-08-16 10:56:38.000000000 +0200
+++ rosetta-patched.js  2011-08-22 17:34:14.000000000 +0200
@@ -13,7 +13,7 @@
             trans=$('textarea',a.parent());
         orig = unescape(orig).replace(/<br\s?\/?>/g,'\n').replace(/<code>/g,'').replace(/<\/code>/g,'').replace(/&gt;/g,'>').replace(/&lt;/g,'<');
         a.attr('class','suggesting').html('...');
-        google.language.translate(orig, '{{MESSAGES_SOURCE_LANGUAGE_CODE}}', 
'{{rosetta_i18n_lang_code}}', function(result) {
+        google.language.translate(orig, '{{MESSAGES_SOURCE_LANGUAGE_CODE}}', 
'{{rosetta_i18n_lang_code|slice:":2"}}', function(result) {
             if (!result.error) {
                 trans.val(unescape(result.translation).replace(/&#39;/g,'\'').replace(/&quot;/g,'"').replace(/%\s+(\([^\)]+\))\s*s/g,' %$1s '));
                 a.hide();

Original issue reported on code.google.com by ppolleunus on 22 Aug 2011 at 3:56

GoogleCodeExporter commented 8 years ago
Thank you for the patch, this was just fixed on GitHub.
https://github.com/mbi/django-rosetta/commit/acbd1ceac05bddebe058edbcba577f97263
0d96e

Original comment by mbonetti on 27 Aug 2011 at 2:52