Fix Astro Cookies for fallback
This commit is contained in:
parent
cdacf37c4a
commit
8da3c92291
1 changed files with 13 additions and 1 deletions
|
@ -3,7 +3,14 @@
|
||||||
import i18next, { t } from "i18next";
|
import i18next, { t } from "i18next";
|
||||||
import { Trans, HeadHrefLangs } from "astro-i18next/components";
|
import { Trans, HeadHrefLangs } from "astro-i18next/components";
|
||||||
|
|
||||||
if (Astro.cookies.get("Language").value === undefined) {Astro.cookies.set("Language", "EN", {path: "/",sameSite: 'strict'})}
|
// Cookies
|
||||||
|
/// Language
|
||||||
|
//// If the user is new to the site, set English as default
|
||||||
|
if (Astro.cookies.get("Language") === undefined) {
|
||||||
|
Astro.cookies.set("Language", "EN", {path: "/",sameSite: 'strict'})
|
||||||
|
}
|
||||||
|
|
||||||
|
//// Check what language the user has set it to and switch to it
|
||||||
var UserLanguage = Astro.cookies.get("Language").value
|
var UserLanguage = Astro.cookies.get("Language").value
|
||||||
if (UserLanguage === "JP") {i18next.changeLanguage("jp")}
|
if (UserLanguage === "JP") {i18next.changeLanguage("jp")}
|
||||||
else if (UserLanguage === "EN") {i18next.changeLanguage("en")}
|
else if (UserLanguage === "EN") {i18next.changeLanguage("en")}
|
||||||
|
@ -13,11 +20,16 @@ const {
|
||||||
Title,
|
Title,
|
||||||
Description
|
Description
|
||||||
} = Astro.props
|
} = Astro.props
|
||||||
|
|
||||||
|
// Components
|
||||||
|
import { ViewTransitions } from 'astro:transitions';
|
||||||
|
import { fade } from "astro/virtual-modules/transitions.js";
|
||||||
---
|
---
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<ViewTransitions transition:animate={fade} />
|
||||||
<title>{Title}</title>
|
<title>{Title}</title>
|
||||||
<link href=/favicon.ico rel=icon>
|
<link href=/favicon.ico rel=icon>
|
||||||
<link rel="manifest" href="/manifest.json">
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
|
Reference in a new issue