Skip to content
Snippets Groups Projects
Commit 98ffe9cb authored by Liam Morland's avatar Liam Morland
Browse files

Issue #3519554: Translate footer links using translatable_menu_link_uri

parent 079e478a
Branches
No related tags found
1 merge request!4Issue #3519554: Use Drupal theme regions in some slots for GCDS header
......@@ -49,6 +49,9 @@ This option is best if all your menu links point to pages within Drupal.
3. Translate the menu as needed.
4. On the theme settings page, select the menu you created in step 1.
If you have menu links translated with `translatable_menu_link_uri` module,
these translated links will be used.
#### Using separate menus for each language
Use this option if your menu includes links to external sites or if your links
......
......@@ -8,5 +8,8 @@
"drupal/core": "^10.3 || ^11.0",
"drupal/simplify_menu": "^3.1",
"drupal/twig_tools": "^2.1"
},
"require-dev": {
"drupal/translatable_menu_link_uri": "^2.1"
}
}
......@@ -20,6 +20,9 @@ dependencies:
- simplify_menu:simplify_menu
- twig_tools:twig_tools
test_dependencies:
- translatable_menu_link_uri:translatable_menu_link_uri
ckeditor5-stylesheets:
- https://cdn.design-system.alpha.canada.ca/@cdssnc/gcds-utility@latest/dist/gcds-utility.min.css
- https://cdn.design-system.alpha.canada.ca/@cdssnc/gcds-components@latest/dist/gcds/gcds.css
......
......@@ -857,12 +857,18 @@ function gcds_preprocess_page(array &$variables): void {
// Get contextual footer links from the configured menu.
$menu_items = _gcds_load_menu_tree(theme_get_setting('footer_menu'));
// Add the menu items to the variables as needed by GCDS.
// Translate menu items with translatable_menu_link_uri if available.
$menu_translation_link_processor = function_exists('translatable_menu_link_uri_iterate_menu');
$footer_items = [];
foreach ($menu_items as $menu_item) {
$menu_item = [
'original_link' => $menu_item->link,
'url' => $menu_item->link->getUrlObject(),
];
// Translate the link.
if ($menu_translation_link_processor) {
translatable_menu_link_uri_iterate_menu($menu_item);
}
$menu_item_name = $menu_item['original_link']->getTitle();
$menu_item_url = $menu_item['url']->toString();
$footer_items[$menu_item_name] = $menu_item_url;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment