-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing translated keys into computed description #123
Comments
Alright. I tried with Then I checked into how metaDefaults is instantiated and added some debug there public function __construct(Page $page, ?string $lang = null)
{
$this->page = $page;
$this->lang = $lang;
if (method_exists($this->page, 'metaDefaults')) {
$this->metaDefaults = $this->page->metaDefaults($this->lang);
}
} And my understanding is that it's always called with $lang as NULL which should explain what happens I guess. 🤔 |
And this is how I fixed public function __construct(Page $page, ?string $lang = null)
{
$this->page = $page;
$this->lang = kirby()->language()->code(); // EDITED
//site()->logger()->debug(kirby()->language()->code());
if (method_exists($this->page, 'metaDefaults')) {
$this->metaDefaults = $this->page->metaDefaults($this->lang);
}
} Not sure if it's 100% clean as I'm not a php expert but it works. Lang code is sent over and translation is done : hope this helps! |
Yes, since it's accessed in the panel it uses your account language and not the page language. |
fyi I was also getting 'NULL' for $lang on the front end side. |
yeah, it's a known issue |
Good luck and thank you again for this great plugin. |
Hi,
I'm trying to set some computed content for description but I'm having difficulties with using a translated string into it.
Here's my code :
The key 'seo.filmBy' should return "Un film de " in FR and "Directed by " in EN. But I'm always getting the FR value (default language) and not the EN value on english version. What's weird is content is translated, meaning
$lang
is passed well right?It's as if $lang was not returning the lang properly into t(). 🤔 I've tried different things without success, any hint would be super helpful 🙏
I wonder how can I try to debug this. For some reasons I don't understand, if I try this to see what's returns
$lang
:I see
$lang
is then NULLBut why is
$missions
translated in the first case then? 🤔Thank you for this great plugin.
The text was updated successfully, but these errors were encountered: