Skip to content

Instantly share code, notes, and snippets.

@stephenbelyea
Last active December 22, 2015 22:20
Show Gist options
  • Save stephenbelyea/2335d862c4faab2f980a to your computer and use it in GitHub Desktop.
Save stephenbelyea/2335d862c4faab2f980a to your computer and use it in GitHub Desktop.
Google Language Translator Accessibility Fixes
// Accessibility fixes for WordPress Google Language Translator plugin.
// Found on WP repo here: https://wordpress.org/plugins/google-language-translator/
// Wait for jQuery to be ready...
// Grab and test for main wrap inserted before script runs.
var glt = document.getElementById('google_language_translator');
if ( $(glt).length ) {
// Allow time for plugin to render.
setTimeout( function (){
// Add label for select and blank alt text for logo images.
var $sel = $(glt).find('select'),
lbl = '<label for="goog-te-combo" class="sr-only">Select a language</label>';
$(lbl).insertBefore($sel);
$sel.attr('id', 'goog-te-combo');
$(glt).find('img').attr('alt', '');
$('#goog-gt-tt').find('.logo img').attr('alt', '');
}, 150);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment