{"id":99159,"date":"2016-12-21T17:04:49","date_gmt":"2016-12-21T17:04:49","guid":{"rendered":"https:\/\/www.megamenu.com\/documentation\/wpml-setup-copy\/"},"modified":"2023-11-20T15:02:49","modified_gmt":"2023-11-20T15:02:49","slug":"polylang","status":"publish","type":"ht_kb","link":"https:\/\/www.megamenu.com\/documentation\/polylang\/","title":{"rendered":"Creating multilingual mega menus with PolyLang"},"content":{"rendered":"\n<p>With Max Mega Menu and PolyLang&nbsp;you can create multilingual&nbsp;Mega Menus for your WordPress site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1<\/h3>\n\n\n\n<p>In this step we assume you <strong>haven&#8217;t<\/strong> installed PolyLang yet, but you&#8217;ve already set up a menu in your native language and enabled Max Mega Menu for it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"2484\" height=\"1762\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-1.png\" alt=\"\" class=\"wp-image-99161\" srcset=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-1.png 2484w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-1-300x213.png 300w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-1-768x545.png 768w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-1-1024x726.png 1024w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-1-50x35.png 50w\" sizes=\"auto, (max-width: 2484px) 100vw, 2484px\" \/><\/a><\/figure>\n\n\n\n<p>Here is how the menu looks on the front end:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"2484\" height=\"1762\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-2.png\" alt=\"\" class=\"wp-image-99162\" srcset=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-2.png 2484w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-2-300x213.png 300w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-2-768x545.png 768w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-2-1024x726.png 1024w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-2-50x35.png 50w\" sizes=\"auto, (max-width: 2484px) 100vw, 2484px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2<\/h3>\n\n\n\n<p>Install PolyLang and set up your languages.<\/p>\n\n\n\n<p>In our example, we&#8217;ll use English and German as our site languages.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"2484\" height=\"1762\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-3.png\" alt=\"\" class=\"wp-image-99163\" srcset=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-3.png 2484w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-3-300x213.png 300w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-3-768x545.png 768w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-3-1024x726.png 1024w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-3-50x35.png 50w\" sizes=\"auto, (max-width: 2484px) 100vw, 2484px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3<\/h3>\n\n\n\n<p>Heading back to <em>Appearance &gt; Menus<\/em>, you should now see that PolyLang has automatically added new menu locations for each of the languages you&#8217;ve set up:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"2484\" height=\"1762\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-4.png\" alt=\"\" class=\"wp-image-99164\" srcset=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-4.png 2484w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-4-300x213.png 300w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-4-768x545.png 768w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-4-1024x726.png 1024w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-4-50x35.png 50w\" sizes=\"auto, (max-width: 2484px) 100vw, 2484px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4<\/h3>\n\n\n\n<p>On the same page, click the &#8220;create a new menu&#8221; link, set up the menu and tag it to the &#8220;Primary Menu <strong>Deutsch<\/strong>&#8221; location.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"2484\" height=\"1762\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-5.png\" alt=\"\" class=\"wp-image-99165\" srcset=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-5.png 2484w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-5-300x213.png 300w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-5-768x545.png 768w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-5-1024x726.png 1024w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-5-50x35.png 50w\" sizes=\"auto, (max-width: 2484px) 100vw, 2484px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">End Result<\/h3>\n\n\n\n<p>We now have 2 menus: one English and one German, each tagged to their respective menu locations.<\/p>\n\n\n\n<p>The English menu will be automatically swapped out for the German&nbsp;menu when the site is viewed in German.<\/p>\n\n\n\n<p>Each menu can be configured independently using all of the available Mega Menu settings.<\/p>\n\n\n\n<p><strong>Note: t<\/strong><strong>he menu theme belonging to the default language menu will always be used, regardless of the language selected. Scroll down for information on translating elements within the menu theme.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-6.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"540\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-6.gif\" alt=\"\" class=\"wp-image-99166\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Translating the Mobile Toggle Blocks<\/h3>\n\n\n\n<p>The menu theme from your default language will be used regardless of the language selected, which means we need to translate the text in the mobile toggle blocks separately.<\/p>\n\n\n\n<p>First, add this to your themes functions.php file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ https:\/\/wordpress.org\/support\/topic\/shortcodes-for-translation-in-place\/\n\/\/ [polylang lang=\"en\"]English[\/polylang][polylang lang=\"de\"]Deutsch[\/polylang]\n\/\/ Add this code in your functions.php\nfunction polylang_shortcode($atts, $content = null) {\n\tif (empty($content)) {\n\t\treturn '';\n\t}\n\t\n\textract( shortcode_atts( array('lang' =&gt; ''), $atts ) );\n\t\n\tif (empty($lang)) {\n\t\treturn \"### You must specify 'lang' using shortcode: polylang\";\n\t}\n\n\treturn ($lang == pll_current_language()) ? $content : '';\n}\nadd_shortcode('polylang', 'polylang_shortcode');\n<\/pre>\n\n\n\n<p>Then construct a shortcode similar to the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[polylang lang=\"en\"]Menu[\/polylang][polylang lang=\"de\"]Men\u00fc[\/polylang]<\/pre>\n\n\n\n<p>.. and paste it into the Toggle Block settings:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1936\" height=\"1548\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode.png\" alt=\"\" class=\"wp-image-233362\" srcset=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode.png 1936w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode-300x240.png 300w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode-1024x819.png 1024w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode-768x614.png 768w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode-50x40.png 50w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2016\/12\/polylang-shortcode-1536x1228.png 1536w\" sizes=\"auto, (max-width: 1936px) 100vw, 1936px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Custom Styling with Max Mega Menu Pro<\/h3>\n\n\n\n<p>If you are having problems with custom styling being applied erratically to your menus, make sure the language selector in your admin bar is set to &#8220;Show all languages&#8221;, then go to Mega Menu &gt; Tools and Clear the CSS cache.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With Max Mega Menu and PolyLang&nbsp;you can create multilingual&nbsp;Mega Menus for your WordPress site. Step 1 In this step we assume you haven&#8217;t installed PolyLang yet, but you&#8217;ve already set up a menu in your native language and enabled Max Mega Menu for it. Here is how the menu looks&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"ht-kb-category":[14],"ht-kb-tag":[],"class_list":["post-99159","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-faqs"],"uagb_featured_image_src":[],"uagb_author_info":{"display_name":"Tom Hemsley","author_link":"https:\/\/www.megamenu.com\/author\/megamenu\/"},"uagb_comment_info":0,"uagb_excerpt":"With Max Mega Menu and PolyLang&nbsp;you can create multilingual&nbsp;Mega Menus for your WordPress site. Step 1 In this step we assume you haven&#8217;t installed PolyLang yet, but you&#8217;ve already set up a menu in your native language and enabled Max Mega Menu for it. Here is how the menu looks...","_links":{"self":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/99159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/comments?post=99159"}],"version-history":[{"count":10,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/99159\/revisions"}],"predecessor-version":[{"id":399737,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/99159\/revisions\/399737"}],"wp:attachment":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/media?parent=99159"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-category?post=99159"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-tag?post=99159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}