Created
September 17, 2014 13:02
-
-
Save bluemango/417064405eba81f1326e to your computer and use it in GitHub Desktop.
Multi language Zendesk search replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adpated from http://pastie.org/5643496#17,19-20,23 | |
// Just add the appropriate strings for the languages you want to support | |
$j(document).ready(function() | |
{ | |
//strip whitespaces from Language-selector | |
function trim11 (str) | |
{ | |
str = str.replace(/^\s+/, ''); | |
for (var i = str.length - 1; i >= 0; i--) { | |
if (/\S/.test(str.charAt(i))) | |
{ | |
str = str.substring(0, i + 1); | |
break; | |
} | |
} | |
return str; | |
} | |
var selectedLang = ""; | |
selectedLang = $j('li.main.right.language_selector a.tab').text(); | |
var search_url, search_label, search_screenteps_label, search_forums_label; | |
if(trim11(selectedLang) === 'Español') | |
{ | |
search_url = ''; | |
search_label = ''; | |
search_screenteps_label = ''; | |
search_forums_text = ''; | |
} | |
if(trim11(selectedLang) === 'Italiano') | |
{ | |
search_url = ''; | |
search_label = ''; | |
search_screenteps_label = ''; | |
search_forums_text = ''; | |
} | |
if(trim11(selectedLang) === 'Netherlands (Dutch)') | |
{ | |
search_url = ''; | |
search_label = ''; | |
search_screenteps_label = ''; | |
search_forums_text = ''; | |
} | |
if(trim11(selectedLang) === 'Deutsch') | |
{ | |
search_url = ''; | |
search_label = ''; | |
search_screenteps_label = ''; | |
search_forums_text = ''; | |
} | |
if(trim11(selectedLang) === 'Русский') | |
{ | |
search_url = ''; | |
search_label = ''; | |
search_screenteps_label = ''; | |
search_forums_text = ''; | |
} | |
else if(trim11(selectedLang) === 'Français') | |
{ | |
search_url = ''; | |
search_label = ''; | |
search_screenteps_label = ''; | |
search_forums_text = ''; | |
} | |
var home_search = $j("#suggestion_submit"); | |
if (home_search) { | |
$j("#search_box").text(search_label); | |
home_search.val(search_forums_label); | |
var html_string = '<input type="submit" name="commit" value="' + search_screenteps_label + '" class="button search primary" id="screensteps-search-submit"/>'; | |
home_search.before(html_string); | |
home_search.removeClass('primary'); | |
$j("#screensteps-search-submit").css("margin-left", "0px").before("<br /><br />"); | |
$j("#screensteps-search-submit").click(function(e){ | |
var search_string = $j("#suggestions_query").val(); | |
var query_string = $j("#suggestions_query").val().replace(/\s/g,"+"); | |
window.location = search_url + "?text=" + query_string; | |
return false; | |
}); | |
}; | |
}); //document |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment