Closed doup closed 2 years ago
@doup Could you try the following and let me know if this solves your problem?
kirby/src/Blueprint/NodeI18n.php
render()
method with this new codepublic function render(ModelWithContent $model): string|null
{
if ($text = I18n::translate($this->translations)) {
return $text;
}
if (isset($this->translations['*']) === true) {
return I18n::translate($this->translations['*'], $this->translations['*']);
}
return $this->translations['en'] ?? null;
}
@distantnative nope, that doesn't do the trick.
Just in case I've tried changing my panel user language from English
to Español
(Spanish), but that didn't change anything. Also, I've double checked in 3.7.0
and it was indeed working:
Ok what I can still reproduce is that there is no fallback when your current language is not any of the languages specified in the blueprint and there is no English one present either.
But if the current language is actually one of the ones specified in the blueprint, it works for me.
Are you sure your user language (Your Account) is set to either eu
or es
? The label translations are based on the Panel user language, not the currently selected content translation language.
Another try for the "missing EN, instead fall back to first defined language" bug:
public function render(ModelWithContent $model): string|null
{
if ($text = I18n::translate($this->translations)) {
return $text;
}
if (isset($this->translations['*']) === true) {
$key = $this->translations['*'];
return I18n::translate($key, $key);
}
if (isset($this->translations['en']) === true) {
return $this->translations['en'];
}
return array_values($this->translations)[0] ?? null;
}
@distantnative In 3.7.5 works sample blueprint and shows first translation as fallback. But in 3.8 doesn't work.
Another try for the "missing EN, instead fall back to first defined language" bug:
This worked for me.
With https://github.com/getkirby/kirby/pull/4728 I would think that it restores same functionality as 3.7.5 for fallbacks.
The latest snippet works for me. I know the Panel language is based on the user language and not the content one. In my case I've the panel user in English… because I just prefer it; but my client will probably use either Spanish or Basque.
Kirby can't assume that the user language will match with the label translations (otherwise it should constraint the user language selection to the ones used in blueprint labels).
No exactly it shouldn't be restricted. But then you were really affected by the last edge case where the user language was not specified. That'll be fixed.
Can we close this after the PR has been merged?
I would think so, yes.
Description
Blueprint field
select
with translated label options is not working anymore. This was working in3.7.0
.Expected behavior
It should show the label.
Screenshots
To reproduce
I'm using the following blueprint config:
Your setup
Kirby Version:
3.8.0-rc.2