Multi-lingual with multi-domain setup

Hello there,

Currently I’m running a website, for example:
domain-a.com/de/home
domain-a.com/en/home

As you can see on domain-a its a multi-lingual site.
German is the default language.

Our customer now would like to have a second domain, with similar content:
domain-b.co.uk/en/home

domain-b would be available only in English.
On some sub-sites domain-b has a few differences compared to domain-a.

What’s the easiest way to implement this when both domains point on the same host/public_html?

Cheers,

frank

When the content is 1-on-1 alike, you can setup localized domains as shown in the docs.

What scares me a bit is “On some sub-sites domain-b has a few differences compared to domain-a”. Be very careful with this.

Hello @bvdputte,

Sorry for my late response

The code defined in the config for each language (en, de) is the same as I can use in the content files (home.en.txt), isn’t it?

So if I’m going to work with more languages as a “placeholder” for “fake-languages” i can use as a code (en2) for my other domain (b)?

I found in the docs that I can set the content with $page->content('en2'). Is there an option to check if the content exsists in en2 or not?

I think I’m near to a good solution for the coming website changes.
Thanks so far!

If you. want to check if the content file exists: https://getkirby.com/docs/cheatsheet/content/exists

The code defined in the config for each language (en, de) is the same as I can use in the content files (home.en.txt), isn’t it?

Yes

So if I’m going to work with more languages as a “placeholder” for “fake-languages” i can use as a code (en2) for my other domain (b)?

I’m not sure you can setup “fake-languages”, when not defined in the config. IIRC the panel needs them to be defined to make the translating possible.

Please also read https://getkirby.com/docs/cookbook/multilanguage-secrets for more insight about multilingual setup.

Thanks!

I define those in the config.
And I still don’t use the panel.

Hello,

The multi-lingual setup is working perfectly.
I have one small problem while building the language navigation over the two domains.

Isn’t it possbile to add custom language variables to my config?

c::set('languages', [
    [
        'code'    => 'de',
        'name'    => 'DE',
        'locale'  => 'de_DE',
        'url'     => '/de',
        'navigation'     => true,
        'default' => true,
    ],
]);

My problem is to access the navigation attribute while creating the navigation:
https://getkirby.com/docs/languages/switching-languages

Any suggestions?

What are you trying to achieve here?

Theoretically,

c::get('languages')['navigation']

should work. But since this is not a default attribute, I’m not sure.

Not every language should be visible in the navigation.

If the above doesn’t work, you can use a separate c::setsetting.

Hello,

I access now the current language info with the following code:

        $languages_code = array_column( c::get('languages'), 'code' );
        $languages_pos  = array_search( $site->language()->code(), $languages_code );
        $language_info  = c::get('languages')[$languages_pos];

This works perfect. Maybe there is a better/faster solution.

Also the check here works in my controllers\site.php

if (!$page->content()->exists()) {
    ...
}

Is there a way to set/overwrite the current content/page object in the controller?
Like:
$page->content('de'); // de = default

Thanks,
frank