Last active
January 31, 2020 15:42
-
-
Save middlesister/f06a064a474bbf48eaa8 to your computer and use it in GitHub Desktop.
Accessible and translatable Genesis reponsive menu
I have tested your code.
I have the following suggestions. I am not very good at coding, but would my best to explain.
- In accessible-genesis-menu.php, line 23, for the "1.0.0", the two full-stop are in different colors (one is blue and one is red), which suggest that the syntax is wrong. This can be fixed by enclosing 1.0.0 with ' ' .
// enqueue the script
wp_enqueue_script( 'prefix-responsive-menu', get_stylesheet_directory_uri() . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0', true );
- In accessible-genesis-menu.php, line 18 and 19, please add a comma after line 19, that is
'responsiveMenubuttonText' => _x( 'Menu', 'Responsive menu button text', 'textdomain'),
Also, someone may use __( ) instead of _x( ) for translating string.
That is
'screenReaderNavHeading' => __( 'Main navigation', 'textdomain' ),
'responsiveMenubuttonText' => __( 'Menu', 'textdomain'),
- In responsive-menu.js, line 5, the translatable variables menuData.screenReaderNavHeading and menuData.responsiveMenubuttonText are in the ' ' string, and this makes the translation fail to work.
You should change it to something like ' + menuData.screenReaderNavHeading + ' and ' + menuData.responsiveMenubuttonText + '
which close the previous string, add variable and then open the next string.
That is to change line 5 to something like the following:
$("header .genesis-nav-menu, .nav-primary .genesis-nav-menu").addClass("responsive-menu").before('<h2 class="screen-reader-text" id="rian-main-nav">' + menuData.screenReaderNavHeading + '</h2><button class="responsive-menu-icon" aria-controls="menu-primary-navigation" aria-expanded="false">' + menuData.responsiveMenubuttonText + '</button>');
Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a translatable version of https://gist.github.com/RRWD/e248ca84ef680c5341f1