diff --git a/package-lock.json b/package-lock.json index 68f43ad..d2cfa17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,12 +5,11 @@ "requires": true, "packages": { "": { - "name": "retrozinn.dev", "version": "0.0.1", "dependencies": { "@astrojs/check": "^0.5.10", "astro": "^4.5.14", - "typescript": "^5.4.3" + "typescript": "^5.4.5" } }, "node_modules/@ampproject/remapping": { @@ -29,6 +28,7 @@ "version": "0.5.10", "resolved": "https://registry.npmjs.org/@astrojs/check/-/check-0.5.10.tgz", "integrity": "sha512-vliHXM9cu/viGeKiksUM4mXfO816ohWtawTl2ADPgTsd4nUMjFiyAl7xFZhF34yy4hq4qf7jvK1F2PlR3b5I5w==", + "license": "MIT", "dependencies": { "@astrojs/language-server": "^2.8.4", "chokidar": "^3.5.3", @@ -5751,9 +5751,10 @@ "integrity": "sha512-OJabfkAg1WLZSqJAJ0Z6Sdt3utnbzr/jh+NAHoyWHJe8CMSy79Gm085094M9nvTPy22KzTVn5Zq5mbapCI/hPA==" }, "node_modules/typescript": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", - "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 7638455..bc8ecfc 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.5.14", "@astrojs/check": "^0.5.10", - "typescript": "^5.4.3" + "astro": "^4.5.14", + "typescript": "^5.4.5" } -} \ No newline at end of file +} diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 0e828d0..54979a2 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -15,13 +15,13 @@ export const en = { projects: "Get in touch with my projects" }, - not_found: { + 404: { title: "404 - Not found!", description: { l1: "Looks like I haven't developed this yet!", - l2: "Feel free to suggest me anything, talk to me on any of", - socials: "my socials!" - } + l2: "Feel free to suggest me anything, talk to me on any of" + }, + socials: "my socials!" }, footer: { diff --git a/src/i18n/pt.ts b/src/i18n/pt.ts index 0409823..67d9cb4 100644 --- a/src/i18n/pt.ts +++ b/src/i18n/pt.ts @@ -15,13 +15,13 @@ export const pt = { projects: "Veja os meus projetos" }, - not_found: { + 404: { title: "404 - Não encontrado!", description: { l1: "Parece que eu ainda não desenvolvi essa página!", - l2: "Se quiser sugerir alguma ideia, me chame em qualquer uma das", - socials: "minhas redes sociais!" - } + l2: "Se quiser sugerir alguma ideia, me chame em qualquer uma das" + }, + socials: "minhas redes sociais!" }, footer: { diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts index 1d346ec..9cad586 100644 --- a/src/i18n/utils.ts +++ b/src/i18n/utils.ts @@ -1,10 +1,9 @@ -import { i18n, defaultLang } from "./ui.ts"; +import { languages, i18n, defaultLang } from "./ui.ts"; export function getLanguageFromURL(url: URL): string { - var splittedURL = url.pathname.split("/"); - var currentIntl = splittedURL[1]; // Gets the second URL part - var domain = splittedURL[0].replace("/", ""); + var splittedURL: string[] = url.pathname.split("/"); + var currentIntl: string = splittedURL[1]; // Gets the second URL part if(currentIntl in i18n) return currentIntl as keyof typeof i18n; @@ -25,3 +24,7 @@ export function useTranslations(lang: keyof typeof i18n): Function { return translation || defaultTranslation || "Couldn't find key to translate."; } } + +export function getLanguages() { + return languages; +} \ No newline at end of file diff --git a/src/pages/404.astro b/src/pages/404.astro index cefa1be..7454841 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -1,13 +1,16 @@ --- -import { getLanguageFromURL, useTranslations } from "../i18n/utils"; +import { getLanguages, getLanguageFromURL, useTranslations } from "../i18n/utils"; import "../styles/global.css"; import NavBar from "../components/NavBar.astro"; -Astro.params.lang = getLanguageFromURL(Astro.url); +Astro.params.lang = "en"; +const langs: string[] = getLanguages(); -if(Astro.params.lang === undefined) { - Astro.params.lang = "en"; -} +langs.forEach(intl => { + if(getLanguageFromURL(Astro.url) == intl) { + Astro.params.lang = intl; + } +}); const tr = useTranslations(Astro.params.lang as never); --- @@ -24,10 +27,10 @@ const tr = useTranslations(Astro.params.lang as never);
-

{ tr("not_found.title") }

+

{ tr("404.title") }

- { tr("not_found.description.l1") }
- { tr("not_found.description.l2") } { tr("not_found.description.socials") } + { tr("404.description.l1") }
+ { tr("404.description.l2") } { tr("404.socials") }