diff --git a/.vscode/settings.json b/.vscode/settings.json index e6e1636..fce7129 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "Mullvad", "nextjs", "Obispo", + "paraglide", "selfhosting", "Syncthing", "Wallabag" diff --git a/languages/en.json b/languages/en.json new file mode 100644 index 0000000..a993d19 --- /dev/null +++ b/languages/en.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://inlang.com/schema/inlang-message-format", + "home_title": "Hello! I'm Bradley Shellnut.", + "home_about": "I'm a full stack software engineer currently working on Java Spring, PostgreSQL, and React / Angular JS.", + "home_learning": "At home you can usually find me learning new things and working with SvelteKit, Next.js, and Gatsby.", + "nav_home": "Home", + "nav_about": "About", + "nav_about_link": "about", + "nav_uses": "Uses", + "nav_uses_link": "uses", + "nav_articles": "Articles", + "nav_articles_link": "articles", + "nav_portfolio": "Portfolio", + "nav_portfolio_link": "portfolio", + "nav_privacy": "Privacy", + "nav_privacy_link": "privacy", + "about_whoami": "Hey! My name is Bradley Shellnut." +} \ No newline at end of file diff --git a/languages/es.json b/languages/es.json new file mode 100644 index 0000000..8a93ecf --- /dev/null +++ b/languages/es.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://inlang.com/schema/inlang-message-format", + "home_title": "!Hola! Me llamo Bradley Shellnut.", + "home_about": "Soy un ingeniero de software de pila completa que actualmente trabaja en Java Spring, PostgreSQL y React / Angular JS.", + "home_learning": "En casa por lo general me puedes encontrar aprendiendo cosas nuevas y trabajando con SvelteKit, Next.js, y Gatsby.", + "nav_home": "Inicio", + "nav_about": "Acerca de", + "nav_about_link": "acerca-de", + "nav_uses": "Utiliza", + "nav_uses_link": "utiliza", + "nav_articles": "Artículos", + "nav_articles_link": "articulos", + "nav_portfolio": "Cartera", + "nav_portfolio_link": "cartera", + "nav_privacy": "Privacidad", + "nav_privacy_link": "privacidad", + "about_whoami": "¡Hola! Me llamo Bradley Shellnut." +} \ No newline at end of file diff --git a/package.json b/package.json index 4cc9808..3f316cf 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "test:ui": "svelte-kit sync && playwright test --ui", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "compile": "paraglide-js compile --project ./project.inlang", + "watch": "paraglide-js compile --project ./project.inlang --watch", "lint": "prettier --plugin-search-dir . --check . && eslint .", "format": "prettier --plugin-search-dir . --write .", "test:integration": "playwright test", diff --git a/project.inlang/settings.json b/project.inlang/settings.json index 320e6e6..0fe625e 100644 --- a/project.inlang/settings.json +++ b/project.inlang/settings.json @@ -2,7 +2,7 @@ "$schema": "https://inlang.com/schema/project-settings", "sourceLanguageTag": "en", "languageTags": [ - "en" + "en", "es" ], "modules": [ "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js", @@ -14,6 +14,6 @@ "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js" ], "plugin.inlang.messageFormat": { - "pathPattern": "./messages/{languageTag}.json" + "pathPattern": "./languages/{languageTag}.json" } } \ No newline at end of file diff --git a/src/app.html b/src/app.html index 6474910..bf73bd9 100644 --- a/src/app.html +++ b/src/app.html @@ -1,5 +1,6 @@ - + +
diff --git a/src/hooks.server.ts b/src/hooks.server.ts new file mode 100644 index 0000000..b683fdb --- /dev/null +++ b/src/hooks.server.ts @@ -0,0 +1,21 @@ +import { getTextDirection } from "$lib/i18n" +import { sourceLanguageTag, type AvailableLanguageTag } from "$paraglide/runtime" + +/* +We set the `lang` and `dir` attributes on the `` element using a hook. +the `app.html` file contains placeholders for these attributes, which we just find and replace. +*/ + +export async function handle({ event, resolve }) { + const lang: AvailableLanguageTag = + (event.params.lang as AvailableLanguageTag) ?? sourceLanguageTag + const textDirection = getTextDirection(lang) + + return await resolve(event, { + transformPageChunk({ done, html }) { + if (done) { + return html.replace("%lang%", lang).replace("%textDir%", textDirection) + } + }, + }) +} \ No newline at end of file diff --git a/src/hooks.ts b/src/hooks.ts new file mode 100644 index 0000000..37ee062 --- /dev/null +++ b/src/hooks.ts @@ -0,0 +1,20 @@ +import type { Reroute } from '@sveltejs/kit'; + +const translated: Record