Site logo

Archived topic

Off Canvas Menu - need in Spanish for Spanish site...

12 replies · Started by Craig on August 3, 2020

Viewing posts 1–13 of 13

Hi -

Can't seem to find or understand how to offer our Spanish menu ( I used the WPML plugin ) in Spanish.

Currently, Customize -> Off Canvas Panel -> Desktop Toggle Label is set to Browse Cards.

Any chance there is a way to have this say 'Examinar Tarjetas' once the URL flips to the /es version?

Thanks so much GP team!

Hi there,

Can you give this PHP snippet a shot and see if it works?

add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
    if ( 'es_ES' === get_locale() ) {
        $settings['mobile_menu_label'] = 'SPANISH TOGGLE TEXT';
    }

    return $settings;
} );

Adding PHP: https://docs.generatepress.com/article/adding-php/

Let me know :)

Thank you! So - I installed in functions.php, and it does not work, the text does not change. With that said, I had trouble running another add_filter with the same type of if ( 'es_ES' === get_locale() ) statement. I ran get_localed() on my server to confirm the es_ES and it does indeed return back the country code, but something is just not allowing that function to return properly.

Do you think it is something I should take up with my host - maybe something not configured correctly with PHP?

Thanks so much!

Craig

Did you add it in the child theme's function.php?

Leo -

I thank you - yes, although I had not set up a child theme yet for this site. It is now set up, I added it in functions.php.

I also put in a quick note to my host support. Happy to give you access and a few bucks via paypal - I appreciate your efforts!

Craig

Leo -

Do you think it SHOULD be working in the child theme? Trying to eliminate GP and see if the host server is the issue?

Thanks, Craig

Can you give this a shot instead?:

add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
    if ( 'es_ES' === get_locale() ) {
        $settings['off_canvas_desktop_toggle_label'] = 'SPANISH TOGGLE TEXT';
    }

    return $settings;
} );

Let me know :)

Tom, thank you so much. Added to child theme to functions.php and does not work. Still shows the text that is in the field with Customizer. I'm sorry this is complicated, appreciate your efforts!

Craig

One thing to try..

In wp-content/plugins/gp-premium, there's a file named: wpml-config.xml

In it, find this entry:

<key name="generate_menu_plus_settings">
    <key name="mobile_menu_label"/>
</key>

And replace it with this:

<key name="generate_menu_plus_settings">
    <key name="mobile_menu_label"/>
    <key name="off_canvas_desktop_toggle_label"/>
</key>

That should make the field translatable within WPML.

Tom - so appreciate the efforts. When I viewed the XML file, that key name for off canvas was actually already in the script. Weird.

I am going to reach out to WPML because I've converted the entire site at this point, with the exception of that one menu label.

Thanks again!

Craig

That's because I added it in 1.11.0 which was released yesterday. The field *should* be translatable by WPML now :)

Ok, got it to work, but I had to place that code in the regular functions.php file, and not my child, which is strange... but seems to work.

There isn't a technical difference between child and parent functions.php files.

You shouldn't ever add anything to the parent theme, as you'll lose everything when you update.

This archived topic is closed to new replies.