• So I found this article:…eate-a-multilingual-site/

    If I choose either route there are issues/questions:

    Separate Sites

    Works better for navigation translation I suppose, however as the site is made and some regions on each page use generic IDs such as page banners, I would have to either go back and change the names (can I do this in admin without having to change the templates?) or have to recreate them on each site!

    Separate Regions
    As I have created the site without adding _en after every region, is this possible? Can I make the default _en regions be the ones without this and then add _de, _es etc? Also using this method how would I change the navigation? Assuming I can only use one navigation layout?

  • I’ve found the key to a multilingual site with perch no matter if you go branched or duplicate region based is making sure that the very first thing you do is detect the language and set a perch system variable for the language so that it can be referenced in templates:

    1. PerchSystem::set_var(‘lang’,$lang);

    with this you can reference the current language pretty much everywhere you need either with :

    1. PerchSystem::get_var(‘lang’);
    2. // or in templates:
    3. <perch:content id=“lang” type=“hidden” />
    4. // or template conditionals
    5. <perch:if id=”lang” match=“eq” value=“en” >Do something for English</perch:if>

    note the type hidden in templates or it will show in the CMS content form

  • So I am trying to build a set of menu translations. I use a layout for my menu. In this example have created a "" file. Inside this is some html. I am stumped how to include the regions!

    I created a shared region with a range of IDs thats in the admin:

    <perch:content id="home-link-de" type="text" label="Home Link DE" />

    <perch:content id="shop-link-de" type="text" label="Shop Link DE" />

    <perch:content id="news-link-de" type="text" label="News Link DE" />

    <perch:content id="shows-link-de" type="text" label="Shows Link DE" />

    <perch:content id="band-link-de" type="text" label="Band Link DE" />

    <perch:content id="media-link-de" type="text" label="Media Link DE" />

    <perch:content id="bookings-link-de" type="text" label="Bookings Link DE" />

    How do I use these inside a layout?

    I tried both these and neither work, the first shows all the above, close but I only want one ID shown. The second doesnt work at all probably because its a php file rather than a html file as its a layout.

    1. <span class="w-nav-title"><perch:content id="home-link-de" type="text"></span>

    2. <span class="w-nav-title"><?php perch_content_custom('Home Link DE', array('template'=>'menu_links_de.html')); ?</span>

    Is there a way to use menu_links_de.html and pull a specific ID from it only?

  • What is the name of your shared region ? 'Home Link DE' ? and the template it uses has a bunch of links ?

    if thats the case and you only want to pull out one of those links by id you can filter the region with perch_content_custom().

    1. perch_content_custom('Home Link DE', [
    2.     'filter' => 'id',
    3.     'match' => 'eq',
    4.     'value' => 'home-link-de',
    5. ]);

    I get the impression you're looking to create a nav menu based for specific languages ? I think there may be simpler solutions for you if this is the case.

  • Okay so my Region is called 'Menu Translations'. Example below based on yours:

    <?php perch_content_custom('Menu Translations',['filter'=>'id','match'=>'eq','value'=>'shop_menu_de']); ?>

    Does not work. It just makes that menu item empty.

    If I just use <?php perch_content_custom('Menu Translations'); ?> then I get all the fields in that shared region.

    What am I doing wrong?

  • Thats what I have done in the end, took me a while to figure out how to implement it. So I am just translating the Nav name inside Perch now.

    This is what I used:

    <?php perch_pages_navigation(array(

    'from-path' => '/de',

    'levels' => 0,

    'hide_extensions' => true,

    'include-parent' => true,

    'template' => array('menu.html')

    )); ?>