Hello Frontity Community,
I’m trying to create a multi-language site using the WP plugin WPML in German and English. We are also using Advanced Custom Fields to display our own modules in the pages. So I created 2 different sites in the same project, inside the frontity settings file. It looks like this:
const settings = [
{
name: "my-example-site",
match: ["http?:\\/\\/[^/]+\\/de([^-\\w]|$)"],
state: {
frontity: {
url: "http://localhost:3000/de",
title: "My Example Site",
description: "Some text here",
}
},
packages: [
{
name: "my-theme",
},
{
name: "@frontity/wp-source",
state: {
source: {
url: "http://myexample.com/de",
homepage: "/home",
subdirectory: "de",
},
theme: {
autoPrefetch: "hover",
},
}
},
"@frontity/tiny-router",
"@frontity/html2react"
]
},
{
name: "my-example-site-en",
match: ["http?:\\/\\/[^/]+\\/en([^-\\w]|$)"],
state: {
frontity: {
url: "http://localhost:3000/en",
title: "My Example Site EN",
description: "Some text here",
}
},
packages: [
{
name: "my-theme",
},
{
name: "@frontity/wp-source",
state: {
source: {
url: "http://myexample.com/en",
homepage: "/home",
subdirectory: "en"
},
theme: {
autoPrefetch: "hover",
},
}
},
"@frontity/tiny-router",
"@frontity/html2react"
]
}
]
In the Page component I get the current language (string) and the current available translations (array) for each page directly from the WP API and then I’m firing 2 actions to set them in the state. After that, the languageToggler component takes both (current language and current translations) and display them inside a select tag, so that I can change the language of each page. This will fire another action to change the state and force a redirection with window.location
Problems I’m getting:
To get the menus I followed this frontity-talk to fetch the menus from WP and it works. The problem comes from the ‘subdirectory’.
When I type subdirectory: "de"
and subdirectory: "en"
in the settings, the menu is not getting fetched - errorStatusText: "No handler has matched for the given link: "/menu/main-menu/""
Without it, the menu appears. But I need the subdirectories in order to display also the content of the pages and no only the menu.
Do you have maybe any idea how to solve this issue? Thank you very much in advance!