Problem with some translation

Hi, I’m trying to understand where is locate the string “Assign a menu” that appear when no menu is set to main menu position.

I have my .po file compiled in italian, but I can’t find this string inside it and consequentially I can’t translate it.

Can you help me?

Thanks

Hello Alessandro,

Thanks for writing in! I can confirm that “Assign a Menu” is not translatable because it was hard coded in one of the theme files. I will report this to our developers so that it can be added to the po file.

Meanwhile, if you want to translate it, assuming your child theme is set up, please add the following code in your child theme’s functions.php file

// Output Primary Navigation
// =============================================================================

if ( ! function_exists( 'x_output_primary_navigation' ) ) :
  function x_output_primary_navigation() {

    if ( x_is_one_page_navigation() ) {

      wp_nav_menu( array(
        'menu'           => x_get_one_page_navigation_menu(),
        'theme_location' => 'primary',
        'container'      => false,
        'menu_class'     => 'x-nav x-nav-scrollspy',
        'link_before'    => '<span>',
        'link_after'     => '</span>'
      ) );

    } elseif ( has_nav_menu( 'primary' ) ) {

      wp_nav_menu( array(
        'theme_location' => 'primary',
        'container'      => false,
        'menu_class'     => 'x-nav',
        'link_before'    => '<span>',
        'link_after'     => '</span>'
      ) );

    } else {

      echo '<ul class="x-nav"><li><a href="' . home_url( '/' ) . 'wp-admin/nav-menus.php">Assign a Menu</a></li></ul>';

    }

  }
endif;

And please do not forget to change the “Assign a Menu” keyword in the code above.

If you need anything else we can help you with, please let us know.

Thank you very much. And if I would like to translate in 3 different languages?

Hey Alessandro,

In that case, you need to make the string translatable like other strings in the theme. Take a look at the code below for example:

echo '<ul class="x-nav"><li><a href="' . home_url( '/' ) . 'wp-admin/nav-menus.php">' . __( 'Assign a Menu', '__x__' ) . '</a></li></ul>';

You can then try to translate using the standard translation method or using the gettext function.

Hope that helps.

Ok, thank you!

You’re welcome! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.