Closed aleclerc7 closed 2 years ago
I would like to add another issue that might be related to this one.
Making the following collection search only work in the main site language:
{% set episodes = page.collection({ items: {'@page.siblings': page.parent.url}, 'filter': { 'type': 'podcast-episode', 'published': true }, 'order': {'by': 'date', 'dir': 'desc'}} ) %}
The reason is that the url has /en/blog
But if the same code is used without the /en
, it works, and returns the pages in English or whatever the language.
{% set episodes = page.collection({ items: {'@page.children': '/blog'}, 'filter': { 'type': 'podcast-episode', 'published': true }, 'order': {'by': 'date', 'dir': 'desc'}} ) %}
I definitely see there is a problem with the presence and absence of /[lang]
codes in the site in general.
Thank you again for your help. Best regards.
This is because i'm liberally using the Twig url()
function all over the place to automatically handle local/relative links so that they work in any scenario. Unfortunately when it comes to multi-lang pages, more logic is needed, such as the Pages::url()
function that can take an optional language string.
This definitely needs addressing but I think it needs to have some thought about the best approach.
BTW, your second comment relates to another issue and potentially a bug in how collections find pages. Do you have a sample "user" folder that already has this multilang configuration I can test with? If so, PM me on discord with the zip file. Thanks!
Can you try something for me?
In Utils.php
line 81 add:
// is this a page?
/** @var Pages $pages */
$pages = $grav['pages'];
$page = $pages->dispatch($input);
if ($page) {
return $page->url($domain);
}
This works for me!
Thank you very much for all your help on this! The patch works.
There is only one problem still with the language switcher coming with Typhoon. It does not give me a correct URL for the default language of the site when the Configuration->Languages->Include default language is set to OFF.
In such a case, when I am:
I am unable to see what it is.
I sent you my /user
. You will be able (hopefully) to see the behaviour.
Thank you and best regards.
Hi there.
I now this thread is old and closed, but was curious how you solved it. I believe I have the same problem as @aleclerc7 described in his / her last post: I have a site with default language in Spanish and additional language in English. Switching from Spanish to English works fine, but switching back does not; in English, the link to switch back to Spanish has /en instead of /.
Thanks and regards, Sebastian
what does your language config look like in system.yaml?
Thanks - it looks like this:
languages:
supported:
- es
- en
default_lang: es
include_default_lang: false
Not sure, but it seems like that include_default_lang
is required to be true
, correct?
At least if I switch it to true
, languageswitcher works correctly.
Yes, that option is typically the favored way of handling multilingual.
Is this the latest version of typhoons langswitcher partial?
Alright - switched it to true.
And yes, it is the latest version of typhoones langswitcher partial. Just compared it to code in the grav-plugin-langswitcher repository.
Hello @sebastian0119,
This behaviour has not been fixed/changed yet. Instead I made a .htaccess that handles and correct the problem (because I am using 3 different domain names in 3 languages, so this was an easy fix). But I certainly would have like it to work properly with include_default_lang=false
.
So my site uses include_default_lang=false
and handles the language switching partly with .htaccess. Doing so gives the desired behaviour.
But if I had only one domain name and multiple languages (like my local dev. env.), I would have liked to have the default language not visible in the URL, but only the other languages.
include_default_lang=false
, it forces the current language.
Kind regards.
Hello,
In a modular page, when using feature.md and hero.md (when creating buttons), the links are not generated properly in multilingual sites.
Same thing for footer Menu Links section.
All other links in the website are correct, having the language prefix.
In admin panel, having Configuration->Languages->Include default language to true changes nothing, except that the same behaviour is seen on the default language. The language prefix in URL is not added.
Thank you for your help and best regards.