Hi,
I would need support on an issue regarding menu configuration files.
In the 'config/global' folder is the menu.php file where clearly the array for rendering the actual menu is to be configured, I would need to make the names of the various menu items translatable e.g. 'Products', 'Customers' etc..
if I try to use the Laravel methods so __("Products") or trans("Products") the software goes into exception because the class 'translator' doesn't exist.
'ReflectionException > BindingResolutionException: Target class [translator] does not exist.'
Clearly this would happen in any file that is present in 'config/', how can I solve it?
Hi Nunzio,
Yes, the solution you implemented in the 'Core/Adapters/Menu' file seems to be valid. By adding the check to ensure the 'attributes' key exists and modifying the 'title' property, you are customizing the menu rendering to include the HTML markup for the 'title' element.
Thanks
Hi Nunzio,
To enable translation for the menu title, please find file in the app/Core/Menu.php
, you can make the following changes:
1. Look for the function _generateItemLinkTitle
2. Find the line that has echo $title;
3. Replace it with
echo __($title);
menu.php
config. For example:"title" => "Products"
__('Products')
, which enables translation for the menu title.Hi, the demo9 I'm using doesn't provide the 'title' property, because if I used it it would mess up the layout, so I made the change in the 'Core/Adampters/Menu' file by going to do this check
if (array_key_exists("attributes", $value)) {
$value["attributes"]["link"]["title"] = "<h6>" . __($value["attributes"]["link"]["title"]) . "</h6>";
}