Skip to content

og-image route returns 404 for non-default language pages with translated slugs #3

Description

@mxmlnbln

In multi-language setups, the (:all)/og-image route strips the language prefix from the slug (line 47) but never calls kirby()->setCurrentLanguage(). Since the route runs in Kirby's main router (no 'language' property), the current language stays on the default. page($slug) then fails to resolve translated slugs because Pages::findByKey() only does translated slug lookups when $kirby->language()->isDefault() === false.

Reproduction:
Kirby multi-language (EN default, DE secondary), page with translated DE slug (e.g. folder publications, DE slug publikationen):

  • /en/publications/my-page/og-image → works (slug matches folder ID)
  • /de/publikationen/my-page/og-image → 404 (fails)

I fixed it with adding kirby()->setCurrentLanguage($slugParts[0]); before stripping the prefix in index.php, but there might be a smoother fix through LanguageRouter.

Version: 1.2.2, Kirby 5.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions