Kookaburra language selector question

PHPlugins function:

		function scripts() {
			echo <<<HTML
				<script>
					const translatePageTitle = (() => {
						if (typeof pageFrontmatter === "undefined") return;
						const titleParts = document.title.split(" - ");
						titleParts.splice(0, 1, pageFrontmatter.title[document.documentElement.lang] || titleParts[0]);
						document.title = titleParts.join(" - ");
					})();
				</script>
HTML;
// do not indent line above
			return false;
		} // END /**/

Remember, you can’t double up on hooks, so if you’re already using the scripts hook, then just copy the JavaScript and add it to your existing function.

Then, on each page you want this to run on, you need to add this frontmatter to your page content:

<script>
  const pageFrontmatter = {
    title: {
      de: "Galerien",
      en: "Galleries",
    },
  }
</script>

<h1 data-lang="en">Galleries</h1><h1 data-lang="de">Galerien</h1>

You don’t need the H1 tags; I’ve included them for the sake of example.