mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-03-05 02:31:42 +01:00
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:
parent
d5164e96c4
commit
2cee519d1c
@ -29,7 +29,7 @@
|
|||||||
$.translate(function(){ //when the Google Language API is loaded
|
$.translate(function(){ //when the Google Language API is loaded
|
||||||
$.translate().ui({
|
$.translate().ui({
|
||||||
tags: ["select", "option"],
|
tags: ["select", "option"],
|
||||||
//a function that filters the languages:
|
// a function that filters the languages:
|
||||||
{% if helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS_LANG %}
|
{% if helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS_LANG %}
|
||||||
filter: {{ helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS_LANG|safe }},
|
filter: {{ helpdesk_settings.HELPDESK_TRANSLATE_TICKET_COMMENTS_LANG|safe }},
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -41,24 +41,23 @@
|
|||||||
function(langCode, lang){
|
function(langCode, lang){
|
||||||
return $.translate.capitalize(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,
|
includeUnknown: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
.change(function(){
|
.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( 'en', { //revert to english first
|
$('#translate_block').translate( '', $(this).val(), { // translate from current language to the selected language
|
||||||
not: 'select, pre'
|
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
|
||||||
.translate( 'en', $(this).val(), {
|
toggle: true, // all translation will be cached (stored with $.data) and used if it's found, or translated to otherwise
|
||||||
not: 'select, pre',
|
walk: true // finds elements having textnodes and translates only their content; on very large and complex pages this might take some time
|
||||||
async: true,
|
})
|
||||||
toggle: true,
|
|
||||||
walk: false
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.val('English') //select English as default
|
.appendTo('#translate_dropdown'); // insert the dropdown menu to the page
|
||||||
.appendTo('#translate_dropdown'); //insert the dropdown to the page
|
|
||||||
|
//insert Google's logo after the dropdown:
|
||||||
|
$.translate.getBranding().appendTo('#translate_dropdown');
|
||||||
|
|
||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user