Skip to content

Commit

Permalink
translate code changes:
Browse files Browse the repository at this point in the history
 - 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.
  • Loading branch information
kotowicz committed Nov 21, 2011
1 parent d5164e9 commit 2cee519
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions helpdesk/templates/helpdesk/base.html
Expand Up @@ -29,7 +29,7 @@
$.translate(function(){ //when the Google Language API is loaded
$.translate().ui({
tags: ["select", "option"],
//a function that filters the languages:
// a function that filters the languages:
{% if helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS_LANG %}
filter: {{ helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS_LANG|safe }},
{% else %}
Expand All @@ -41,24 +41,23 @@
function(langCode, lang){
return $.translate.capitalize(lang);
},
//whether to include the UNKNOWN:"" along with the languages:
// whether to include the UNKNOWN:"" along with the languages:
includeUnknown: false,
})

.change(function(){
$('#translate_block').translate( 'en', { //revert to english first
not: 'select, pre'
})

.translate( 'en', $(this).val(), {
not: 'select, pre',
async: true,
toggle: true,
walk: false
});
.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
})
})
.val('English') //select English as default
.appendTo('#translate_dropdown'); //insert the dropdown to the page
.appendTo('#translate_dropdown'); // insert the dropdown menu to the page

//insert Google's logo after the dropdown:
$.translate.getBranding().appendTo('#translate_dropdown');

});
{% endif %}
Expand Down

0 comments on commit 2cee519

Please sign in to comment.