You cannot localize variables, they need to be fixed strings. Variables can only be incorporated using printf() format where placeholders like %s occur where a variable’s value would be placed. Of course the variable itself is not translated, just the string around it.
The nav menu normally does not have any fixed strings except maybe “menu”. Everything is based on user input, user input cannot be localized.
https://developer.wordpress.org/themes/functionality/localization/
ok. Any other option to do the trick? Because I need to have a navigation that has two language one for english (default) and second option for (arabic). I saw some sites that their navigation will translate to different language but I have no idea how they do it.
You’d need different menus defined for each location, one for each language. Each menu item is a special post type: nav_menu_item. There is a special taxonomy to determine what menu each post belongs to: nav_menu. All posts in a menu are assigned the same term. The term ID of the menu is assigned to a menu location in the theme mod settings in the options table. The option key is “theme_mods_{$theme_name}”.
To swap menus, determine the term ID from the terms table based on the menu name. Confirm the term is in the right taxonomy with the term_taxonomy table. Set the ID for the menu location in the theme mods option.
Then when wp_nav_menu() is called for a particular location, WP gets the nav_menu posts that have the menu name term assigned which corresponds to the ID saved in theme mods. The menu order and parent values are used to construct the menu.