Skip to main content
Changed the answer following the update in the OP
Source Link

Look at yourThe following code a bit closerdoes what you seem to need (screenshots attached). The following modules need to be activated:

  • i18n_menu (part of the i18n)

You are addingFurther configuration:

  • I added a new language (tr) and set language detection to "Determine the language from the URL (Path prefix or domain)."

  • I added a new menu with machine name (menu-sol-menu) and set the translation mode to "Translate and Localize". Also added the new menu as a block to the header region of the theme.

  • Added the following code in a custom module and activated it.

     function agi_menu() {
       $items = [];
       $items['agi'] = [
         'title' => 'AGI (Family Status Declaration)',
         'page callback' => 'drupal_get_form',
         'page arguments' => ['node_form'],
         'access arguments' => ['access content'],
         'menu_name' => 'menu-sol-menu'
       ];
       return $items;
     }
    

I visited the menu admin page and saw that a new menu item, in every iteration, using was added:

enter image description here

I checked the exact same keylanguage option for that new menu item, 'agi'it was set to neutral. In

enter image description here

I visited the end, your $items array holds only onehome page of my drupal instance and checked that the menu item appears, for the last language returned by theboth english language_list() function(default language) and turkish, apparently Turkishusing the URL to define the current language.

Hope this helps!enter image description here

P.S.: Below is a rewrite of your codeFinally, withoutI looked in the needtranslate interface for a loopthe title of the menu item. This implies activating

enter image description here

Conclusion: The provided code with the "Content Translation" module from coredescribed configuration works as expected by the OP.

Good luck!

N.B.: Especially for the 'title' and 'title callback' properties, the documentation is very clear about how to use them in a multilingual setting

"title": Required. The untranslated title of the menu item. "title callback": Function to generate the title; defaults to t(). If you require only the raw string to be output, set this to FALSE.

function suweb_agi_menu() {
  $items = [];
  $items['agi'] = [
    'title' => 'AGİ (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['suweb_agi_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}

Look at your code a bit closer:

You are adding a menu item, in every iteration, using the exact same key, 'agi'. In the end, your $items array holds only one menu item, for the last language returned by the language_list() function, apparently Turkish.

Hope this helps!

P.S.: Below is a rewrite of your code, without the need for a loop. This implies activating the "Content Translation" module from core. Especially for the 'title' and 'title callback' properties, the documentation is very clear about how to use them in a multilingual setting

"title": Required. The untranslated title of the menu item. "title callback": Function to generate the title; defaults to t(). If you require only the raw string to be output, set this to FALSE.

function suweb_agi_menu() {
  $items = [];
  $items['agi'] = [
    'title' => 'AGİ (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['suweb_agi_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}

The following code does what you seem to need (screenshots attached). The following modules need to be activated:

  • i18n_menu (part of the i18n)

Further configuration:

  • I added a new language (tr) and set language detection to "Determine the language from the URL (Path prefix or domain)."

  • I added a new menu with machine name (menu-sol-menu) and set the translation mode to "Translate and Localize". Also added the new menu as a block to the header region of the theme.

  • Added the following code in a custom module and activated it.

     function agi_menu() {
       $items = [];
       $items['agi'] = [
         'title' => 'AGI (Family Status Declaration)',
         'page callback' => 'drupal_get_form',
         'page arguments' => ['node_form'],
         'access arguments' => ['access content'],
         'menu_name' => 'menu-sol-menu'
       ];
       return $items;
     }
    

I visited the menu admin page and saw that a new menu item was added:

enter image description here

I checked the language option for that new menu item, it was set to neutral.

enter image description here

I visited the home page of my drupal instance and checked that the menu item appears, for both english (default language) and turkish, using the URL to define the current language.

enter image description here

Finally, I looked in the translate interface for the title of the menu item.

enter image description here

Conclusion: The provided code with the described configuration works as expected by the OP.

Good luck!

N.B.: Especially for the 'title' and 'title callback' properties, the documentation is very clear about how to use them in a multilingual setting

"title": Required. The untranslated title of the menu item. "title callback": Function to generate the title; defaults to t(). If you require only the raw string to be output, set this to FALSE.

Provided a code sample
Source Link

Look at your code a bit closer:

You are adding a menu item, in every iteration, using the exact same key, 'agi'. In the end, your $items array holds only one menu item, for the last language returned by the language_list() function, apparently Turkish.

Hope this helps!

P.S.: Below is a rewrite of your code, without the need for a loop. This implies activating the "Content Translation" module from core. Especially for the 'title' and 'title callback' properties, the documentation is very clear about how to use them in a multilingual setting

"title": Required. The untranslated title of the menu item. "title callback": Function to generate the title; defaults to t(). If you require only the raw string to be output, set this to FALSE.

function suweb_agi_menu() {
  $items = [];
  $items['agi'] = [
    'title' => 'AGİ (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['suweb_agi_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}

Look at your code a bit closer:

You are adding a menu item, in every iteration, using the exact same key, 'agi'. In the end, your $items array holds only one menu item, for the last language returned by the language_list() function, apparently Turkish.

Hope this helps!

Look at your code a bit closer:

You are adding a menu item, in every iteration, using the exact same key, 'agi'. In the end, your $items array holds only one menu item, for the last language returned by the language_list() function, apparently Turkish.

Hope this helps!

P.S.: Below is a rewrite of your code, without the need for a loop. This implies activating the "Content Translation" module from core. Especially for the 'title' and 'title callback' properties, the documentation is very clear about how to use them in a multilingual setting

"title": Required. The untranslated title of the menu item. "title callback": Function to generate the title; defaults to t(). If you require only the raw string to be output, set this to FALSE.

function suweb_agi_menu() {
  $items = [];
  $items['agi'] = [
    'title' => 'AGİ (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['suweb_agi_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}
Source Link

Look at your code a bit closer:

You are adding a menu item, in every iteration, using the exact same key, 'agi'. In the end, your $items array holds only one menu item, for the last language returned by the language_list() function, apparently Turkish.

Hope this helps!