translate code changes:

- change js code, so that 'click' and not 'change' will trigger the translation.
 - do not assume that English is the source language - the comments might be in a different language.
This commit is contained in:
Andreas Kotowicz 2011-11-21 19:15:43 +01:00
parent d5164e96c4
commit 2cee519d1c

View File

@ -45,20 +45,19 @@
includeUnknown: false,
})
.change(function(){
$('#translate_block').translate( 'en', { //revert to english first
not: 'select, pre'
.click(function(){ // when selecting a language - 'change' is not enough, because your first language in the menu might be your target language
$('#translate_block').translate( '', $(this).val(), { // translate from current language to the selected language
not: '.option, select, pre, .translate_dropdown', // exclude these elements
fromOriginal: true, // always translate from original version (even after the page has been translated)
async: true, // this prevents the browser from freezing on larger sites by executing each DOM filtering iteration with a delay
toggle: true, // all translation will be cached (stored with $.data) and used if it's found, or translated to otherwise
walk: true // finds elements having textnodes and translates only their content; on very large and complex pages this might take some time
})
})
.appendTo('#translate_dropdown'); // insert the dropdown menu to the page
.translate( 'en', $(this).val(), {
not: 'select, pre',
async: true,
toggle: true,
walk: false
});
})
.val('English') //select English as default
.appendTo('#translate_dropdown'); //insert the dropdown to the page
//insert Google's logo after the dropdown:
$.translate.getBranding().appendTo('#translate_dropdown');
});
{% endif %}