diff --git a/package-lock.json b/package-lock.json index 332ad87..68f43ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "retrozinn.dev", "version": "0.0.1", "dependencies": { "@astrojs/check": "^0.5.10", @@ -1658,11 +1659,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2411,9 +2413,10 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -2971,6 +2974,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -5673,6 +5677,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, diff --git a/src/components/NavBar.astro b/src/components/NavBar.astro index ab0a6f0..4d614cb 100644 --- a/src/components/NavBar.astro +++ b/src/components/NavBar.astro @@ -1,17 +1,10 @@ --- +import { useTranslations } from "../i18n/utils.ts"; import "../styles/global.css"; -var options = { - Home: "Home", - About: "About Me", - Projects: "Projects" -}; +const tr = useTranslations(Astro.params.lang as never); --- - - @@ -21,13 +14,13 @@ var options = { - { options.Home } + { tr("nav.home") } - { options.About } + { tr("nav.about") } - { options.Projects } + { tr("nav.projects") } diff --git a/src/env.d.ts b/src/env.d.ts index f964fe0..acef35f 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1 +1,2 @@ +/// /// diff --git a/src/i18n/en.ts b/src/i18n/en.ts new file mode 100644 index 0000000..a21c270 --- /dev/null +++ b/src/i18n/en.ts @@ -0,0 +1,24 @@ +export const en = { + + nav: { + home: "Home", + about: "About", + projects: "Projects" + }, + + about: { + title: "Hi, I'm", + description: `I'm a self-taught programmer and tech enthusiast who's learning software + development stuff! I absolutely love making open-source projects! I like: coding, + learning about Linux and making games and apps in my free time!`, + socials_title: "You can find me in:", + projects: "Get in touch with my projects" + }, + + not_found: { + title: "404 - Not found!", + description: `Looks like I haven't developed this yet! + Feel free to suggest me anything, talk to me on any of`, + social_link: "my socials!" + } +} as const; \ No newline at end of file diff --git a/src/i18n/pt.ts b/src/i18n/pt.ts new file mode 100644 index 0000000..40425f1 --- /dev/null +++ b/src/i18n/pt.ts @@ -0,0 +1,24 @@ +export const pt = { + + nav: { + home: "Início", + about: "Sobre mim", + projects: "Projetos" + }, + + about: { + title: "Olá, sou o", + description: `Sou um programador autodidata e entusiasta de tecnologia que está amando o + mundo da programação! Eu gosto muito de fazer projetos open-source! Eu curto: programar, + aprender sobre GNU/Linux, fazer jogos e aplicativos no meu tempo livre!`, + socials_title: "Você pode me encontrar em:", + projects: "Veja os meus projetos" + }, + + not_found: { + title: "404 - Não encontrado!", + description: `Parece que eu ainda não desenvolvi essa página! + Feel free to suggest me anything, talk to me on any of`, + social_link: "minhas redes sociais!" + } +} as const; \ No newline at end of file diff --git a/src/i18n/route.ts b/src/i18n/route.ts new file mode 100644 index 0000000..3f0cae4 --- /dev/null +++ b/src/i18n/route.ts @@ -0,0 +1,5 @@ + +import { languages } from "./ui"; + +export const getStaticPaths = () => + languages.map(lang => ({ params: { lang } })); \ No newline at end of file diff --git a/src/i18n/ui.ts b/src/i18n/ui.ts new file mode 100644 index 0000000..526d9b4 --- /dev/null +++ b/src/i18n/ui.ts @@ -0,0 +1,17 @@ + +import { en } from"./en.ts"; +import { pt } from "./pt.ts"; + +export let i18n: object = { + en: { + ...en + }, + pt: { + ...pt + } +}; + +export const languages: Array = Object.keys(i18n); +export const defaultLang = "en" as keyof typeof i18n; + +console.log(languages); diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts new file mode 100644 index 0000000..1d346ec --- /dev/null +++ b/src/i18n/utils.ts @@ -0,0 +1,27 @@ + +import { 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("/", ""); + + if(currentIntl in i18n) + return currentIntl as keyof typeof i18n; + + return currentIntl as string; +} + +export function useTranslations(lang: keyof typeof i18n): Function { + return function tr(key: string): string { + const keys = key.split("."); + let translation = i18n[lang], defaultTranslation = i18n[defaultLang]; + + keys.forEach(key => { + translation = translation[key]; + defaultTranslation = defaultTranslation[key]; + }); + + return translation || defaultTranslation || "Couldn't find key to translate."; + } +} diff --git a/src/pages/404.astro b/src/pages/404.astro index dfe3a54..f0b3db4 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -1,21 +1,32 @@ --- + import "../styles/global.css"; import NavBar from "../components/NavBar.astro"; -import PageLayout from "../layouts/PageLayout.astro"; --- + + + + + + retrozinndev - Not Found! + + - + - 404! + 404! - Looks like I didn't developed this yet! + Looks like I haven't developed this yet! Feel free to suggest me anything, talk to me on any of my socials! - + + + +
- Looks like I didn't developed this yet! + Looks like I haven't developed this yet! Feel free to suggest me anything, talk to me on any of my socials!