Deactivate languages in frontend, but not in panel

As there is actually no way to publish translated pages individually from their main language (they always both have the same state) I thought about other ways letting authors still create multilingual content, but not yet make it available in the frontend.

A scenario here is that I often build multilingual websites, but at the day of launch, the translations are not yet ready, so to not screw with the SEO ranking, I want to deactivate the rendering of a whole language.

What would be the correct way to achieve something like that? E.g. with hooks, that soft or hard redirect to the main language version of a page if language detection or URL for a different language is accessed.

The URL for the main language, let’s say English, should still be en/, to not have to deal with redirects as soon as the second language is made public. That’s why I can’t just deactivate certain multilingual features.

Bonus point: When the pages can still be viewed in the frontend when logged in (e.g. by token check).

I don’t expect that somebody comes up with a final solution. What would help me actually is to know where to get started, which parts of Kirby, e.g. maybe hooks, should be used for that.

For the language switcher snippet in the frontend, use an “active languages array” to iterate over instead of the $kirby->languages().

For the redirects you can use language specific routes, maybe in conjunction with a toggle field value that determines if a translation is published.

I do this with the “not method” on my language navigation:

$kirby->languages()->not(['en','es'])

Then disable sitemaps and thelink rel="alternate" tags on the document head .