šŸ“œ ā¬†ļø ā¬‡ļø

Multilingual in Drupal 7. Menu

Earlier, I told you how quickly and easily you can transfer content (nodes) to D7.
Now I will talk about 2 ways to translate the menu.

In both cases we will use the i18n, i18n_menu modules. At this time, Entity translation is not a helper for us, since it can only translate an entity. In Drupal 6, Menu Translation was used for this, later it was merged with Internationalization .


It is assumed that the i18n module is already enabled and language definitions are configured (if not, go here ).
First of all, let's turn on the submodule for translating the menu, use drush.
drush en -y i18n_menu

Method one


On the edit page of the ā€œadmin / structure / menu / manage /% menu% / editā€ menu, select the ā€œTranslate and Localizeā€ item.

')
As you can see, a new ā€œTranslateā€ tab has appeared on the menu page.


With it you can translate the name and description of this menu.


When you create a new link in the menu, the language selection box appears.
Important : the language must be chosen, otherwise this link will not be translated in this way.


On the ā€œadmin / structure / menu / item /% menu_item_id% / translateā€ page, you can add a new translation to this link, or you can specify an existing translation.


As a result of the translation, the links are duplicated, but with different languages.


Second way


In the second method, we will use the same module, but differently.

Important: when creating a new link, you must select a neutral language.


Everything can now be translated. This is done on one of two pages of your choice:
Through the ā€œTranslateā€ tab on the link editing page.

Or on the "admin / config / regional / translate / translate" page.

When using the second method, the links themselves are not duplicated.

Result

English:
Deutsch:

Update

If you are going to output programmatically, you must use the function
 <?php print render( i18n_menu_translated_tree('menu-name') ); ?> 
instead
 <?php print render( menu_tree('menu-name') ); ?> 

Source: https://habr.com/ru/post/150677/


All Articles