An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Begin translation and finish i18n system
Restray269250ef3d8b
diff --git a/.vscode/settings.json b/.vscode/settings.jsonindex ab2903b569..b823b00012 100644--- a/.vscode/settings.json+++ b/.vscode/settings.json@@ -1,8 +1,8 @@{- "i18n-ally.localesPaths": ["static/locales"],+ "i18n-ally.localesPaths": ["src/lib/locales"],"i18n-ally.keystyle": "nested","i18n-ally.extract.ignoredByFiles": {"src\\routes\\__layout.svelte": ["Coolify", "coolLabs logo"]},- "i18n-ally.sourceLanguage": "fr"+ "i18n-ally.sourceLanguage": "en"}diff --git a/src/app.d.ts b/src/app.d.tsindex 0557299b92..6dacd83950 100644--- a/src/app.d.ts+++ b/src/app.d.ts@@ -23,6 +23,7 @@ interface SessionData {userId?: string | null;teamId?: string | null;permission?: string;+ lang?: string;isAdmin?: boolean;expires?: string | null;gitlabToken?: string | null;diff --git a/src/hooks.ts b/src/hooks.tsindex e0e4707cb1..ac60a2a25b 100644--- a/src/hooks.ts+++ b/src/hooks.ts@@ -18,27 +18,22 @@ export const handle = handleSession(let response;const { url, request } = event;- const { pathname } = url;// Get defined localesconst supportedLocales = locales.get();let locale;- if (event.locals.cookies) {- locale = supportedLocales.find(- (l) => `${l}`.toLowerCase() === `${event.locals.cookies['lang']}`.toLowerCase()- );- }-- if (!locale) {+ if (event.locals.cookies['lang']) {+ locale = event.locals.cookies['lang'];+ } else if (!locale) {locale = `${`${request.headers.get('accept-language')}`.match(/[a-zA-Z]+?(?=-|_|,|;)/)}`.toLowerCase();-- // Set default locale if user preferred locale does not match- if (!supportedLocales.includes(locale)) locale = 'en';}+ // Set default locale if user preferred locale does not match+ if (!supportedLocales.includes(locale)) locale = 'en';+try {if (event.locals.cookies) {if (event.locals.cookies['kit.session']) {@@ -105,7 +100,18 @@ export const handle = handleSession();export const getSession: GetSession = function ({ locals }) {+ // Get defined locales+ const supportedLocales = locales.get();+ let locale;++ if (locals.cookies) {+ locale = supportedLocales.find(+ (l) => `${l}`.toLowerCase() === `${locals.cookies['lang']}`.toLowerCase()+ );+ }+return {+ lang: locale,version,...locals.session.data};diff --git a/src/lib/locales/en.json b/src/lib/locales/en.jsonnew file mode 100644index 0000000000..a6a99215b5--- /dev/null+++ b/src/lib/locales/en.json@@ -0,0 +1,40 @@+{+ "layout": {+ "update_done": "Update completed.",+ "wait_new_version_startup": "Waiting for the new version to start...",+ "new_version": "New version reachable. Reloading...",+ "switch_to_a_different_team": "Switch to a different team...",+ "update_available": "Update available"+ },+ "error": {+ "you_can_find_your_way_back": "You can find your way back",+ "here": "here"+ },+ "index": {+ "dashboard": "Dashboard",+ "applications": "Applications",+ "destinations": "Destinations",+ "git_sources": "Git Sources",+ "databases": "Databases",+ "services": "Services",+ "teams": "Teams"+ },+ "login": {+ "already_logged_in": "Already logged in...",+ "authenticating": "Authenticating...",+ "login": "Login"+ },+ "forms": {+ "password": "Password",+ "email": "Email",+ "passwords_not_match": "Passwords do not match.",+ "password_again": "Password again"+ },+ "register": {+ "register": "Register",+ "first_user": "You are registering the first user. It will be the administrator of your Coolify instance."+ },+ "reset": {+ "reset_password": "Reset password"+ }+}diff --git a/src/lib/locales/fr.json b/src/lib/locales/fr.jsonnew file mode 100644index 0000000000..d52be99896--- /dev/null+++ b/src/lib/locales/fr.json@@ -0,0 +1,40 @@+{+ "index": {+ "dashboard": "Tableau de bord",+ "applications": "Applications",+ "databases": "Bases de données",+ "destinations": "Destinations",+ "git_sources": "Sources Git",+ "services": "Prestations de service",+ "teams": "Équipes"+ },+ "error": {+ "here": "ici",+ "you_can_find_your_way_back": "Tu peux retrouver ton chemin"+ },+ "forms": {+ "email": "E-mail",+ "password": "Mot de passe",+ "password_again": "Retaper le mot de passe",+ "passwords_not_match": "Les mots de passe ne correspondent pas."+ },+ "layout": {+ "new_version": "Nouvelle version disponible. \nActualisation...",+ "switch_to_a_different_team": "Changer d'équipe...",+ "update_available": "Mise à jour disponible",+ "update_done": "Mise à jour terminée.",+ "wait_new_version_startup": "Attente du lancement de la nouvelle version..."+ },+ "login": {+ "already_logged_in": "Déjà connecté...",+ "authenticating": "Authentification...",+ "login": "Connexion"+ },+ "register": {+ "first_user": "Vous enregistrez le premier utilisateur. \nCe sera l'administrateur de votre instance Coolify.",+ "register": "S'inscrire"+ },+ "reset": {+ "reset_password": "Réinitialiser le mot de passe"+ }+}diff --git a/src/lib/translations.ts b/src/lib/translations.tsindex 69282b21c4..9d31f11bf7 100644--- a/src/lib/translations.ts+++ b/src/lib/translations.ts@@ -3,7 +3,6 @@ import lang from './lang.json';/** @type {import('sveltekit-i18n').Config} */const config = {- defaultLocale: 'en',fallbackLocale: 'en',translations: {en: { lang },@@ -13,16 +12,16 @@ const config = {{locale: 'en',key: '',- loader: async () => (await import('../../static/locales/en.json')).default+ loader: async () => (await import('./locales/en.json')).default},{locale: 'fr',key: '',- loader: async () => (await import('../../static/locales/fr.json')).default+ loader: async () => (await import('./locales/fr.json')).default}]};-export const { t, locale, locales, loading, loadTranslations } = new i18n(config);+export const { t, loading, locales, locale, loadTranslations } = new i18n(config);-loading.subscribe(($loading) => $loading && console.log('Loading translations...'));+loading.subscribe(($loading) => $loading);diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelteindex ceaf7cffbb..7d6946b8d5 100644--- a/src/routes/__layout.svelte+++ b/src/routes/__layout.svelte@@ -4,6 +4,11 @@import { locale, loadTranslations } from '$lib/translations';export const load: Load = async ({ fetch, url, session }) => {+ const { pathname } = url;+ const initLocale = locale.get() || session.lang || 'en';++ await loadTranslations(initLocale, pathname);+if (!session.userId && !publicPaths.includes(url.pathname)) {return {status: 302,@@ -16,12 +21,6 @@const endpoint = `/teams.json`;const res = await fetch(endpoint);- const { pathname } = url;- const defaultLocale = session.lang;- const initLocale = locale.get() || defaultLocale;-- await loadTranslations(initLocale, pathname);-if (res.ok) {return {props: {diff --git a/src/routes/index.svelte b/src/routes/index.svelteindex 2e3fc51378..ba7dd18a11 100644--- a/src/routes/index.svelte+++ b/src/routes/index.svelte@@ -46,7 +46,7 @@class="flex cursor-pointer flex-col rounded p-6 text-center text-green-500 no-underline transition duration-150 hover:bg-green-500 hover:text-white"><dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">- Applications+ {$t('index.applications')}</dt><dd class="order-1 text-5xl font-extrabold ">{applicationsCount}@@ -58,7 +58,7 @@class="flex cursor-pointer flex-col rounded p-6 text-center text-sky-500 no-underline transition duration-150 hover:bg-sky-500 hover:text-white"><dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">- Destinations+ {$t('index.destinations')}</dt><dd class="order-1 text-5xl font-extrabold ">{destinationsCount}@@ -70,7 +70,7 @@class="flex cursor-pointer flex-col rounded p-6 text-center text-orange-500 no-underline transition duration-150 hover:bg-orange-500 hover:text-white"><dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">- Git Sources+ {$t('index.git_sources')}</dt><dd class="order-1 text-5xl font-extrabold ">{sourcesCount}@@ -81,7 +81,9 @@sveltekit:prefetchclass="flex cursor-pointer flex-col rounded p-6 text-center text-purple-500 no-underline transition duration-150 hover:bg-purple-500 hover:text-white">- <dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">Databases</dt>+ <dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">+ {$t('index.databases')}+ </dt><dd class="order-1 text-5xl font-extrabold ">{databasesCount}</dd></a><a@@ -89,7 +91,9 @@sveltekit:prefetchclass="flex cursor-pointer flex-col rounded p-6 text-center text-pink-500 no-underline transition duration-150 hover:bg-pink-500 hover:text-white">- <dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">Services</dt>+ <dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">+ {$t('index.services')}+ </dt><dd class="order-1 text-5xl font-extrabold ">{servicesCount}</dd></a>@@ -98,7 +102,9 @@sveltekit:prefetchclass="flex cursor-pointer flex-col rounded p-6 text-center text-cyan-500 no-underline transition duration-150 hover:bg-cyan-500 hover:text-white">- <dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">Teams</dt>+ <dt class="order-2 mt-2 text-sm font-bold uppercase leading-6 text-white">+ {$t('index.teams')}+ </dt><dd class="order-1 text-5xl font-extrabold ">{teamsCount}</dd>diff --git a/src/routes/login/index.svelte b/src/routes/login/index.svelteindex b321bc0867..6b3c796794 100644--- a/src/routes/login/index.svelte+++ b/src/routes/login/index.svelte@@ -4,6 +4,7 @@import { session } from '$app/stores';import { post } from '$lib/api';import { errorNotification } from '$lib/form';+ import { t } from '$lib/translations';import { onMount } from 'svelte';let loading = false;let emailEl;@@ -37,9 +38,13 @@}</script>+<svelt:head>+ <title>{$t('login.login')}</title>+</svelt:head>+<div class="flex h-screen flex-col items-center justify-center">{#if $session.userId}- <div class="flex justify-center px-4 text-xl font-bold">Already logged in...</div>+ <div class="flex justify-center px-4 text-xl font-bold">{$t('login.already_logged_in')}</div>{:else}<div class="flex justify-center px-4"><form on:submit|preventDefault={handleSubmit} class="flex flex-col py-4 space-y-2">@@ -48,7 +53,7 @@<inputtype="email"name="email"- placeholder="Email"+ placeholder={$t('forms.email')}autocomplete="off"requiredbind:this={emailEl}@@ -57,7 +62,7 @@<inputtype="password"name="password"- placeholder="Password"+ placeholder={$t('index.password')}bind:value={password}required/>@@ -69,16 +74,18 @@class="hover:opacity-90 text-white"class:bg-transparent={loading}class:text-stone-600={loading}- class:bg-coollabs={!loading}>{loading ? 'Authenticating...' : 'Login'}</button+ class:bg-coollabs={!loading}+ >{loading ? $t('login.authenticating') : $t('login.login')}</button><buttonon:click|preventDefault={() => goto('/register')}- class="bg-transparent hover:bg-coolgray-300 text-white ">Register</button+ class="bg-transparent hover:bg-coolgray-300 text-white "+ >{$t('register.register')}</button><buttonclass="bg-transparent hover:bg-coolgray-300"- on:click|preventDefault={() => goto('/reset')}>Reset password</button+ on:click|preventDefault={() => goto('/reset')}>{$t('reset.reset_password')}</button></div></form>diff --git a/src/routes/register/index.svelte b/src/routes/register/index.svelteindex 35501fce20..9de0626dbd 100644--- a/src/routes/register/index.svelte+++ b/src/routes/register/index.svelte@@ -6,6 +6,7 @@import { session } from '$app/stores';import { post } from '$lib/api';import { errorNotification } from '$lib/form';+ import { t } from '$lib/translations';import { onMount } from 'svelte';let loading = false;@@ -20,7 +21,7 @@});async function handleSubmit() {if (password !== passwordCheck) {- return errorNotification('Passwords do not match.');+ return errorNotification($t('forms.passwords_not_match'));}loading = true;try {@@ -57,7 +58,7 @@</div><div class="flex h-screen flex-col items-center justify-center">{#if $session.userId}- <div class="flex justify-center px-4 text-xl font-bold">Already logged in...</div>+ <div class="flex justify-center px-4 text-xl font-bold">{$t('login.already_logged_in')}</div>{:else}<div class="flex justify-center px-4"><form on:submit|preventDefault={handleSubmit} class="flex flex-col py-4 space-y-2">@@ -66,7 +67,7 @@<inputtype="email"name="email"- placeholder="Email"+ placeholder={$t('forms.email')}autocomplete="off"requiredbind:this={emailEl}@@ -75,28 +76,28 @@<inputtype="password"name="password"- placeholder="Password"+ placeholder={$t('forms.password')}bind:value={password}required/><inputtype="password"name="passwordCheck"- placeholder="Password again"+ placeholder={$t('forms.password_again')}bind:value={passwordCheck}required/><div class="flex space-x-2 h-8 items-center justify-center pt-8"><button type="submit" class="hover:bg-coollabs-100 text-white bg-coollabs"- >Register</button+ >{$t('register.register')}</button></div></form></div>{#if userCount === 0}<div class="pt-5">- You are registering the first user. It will be the administrator of your Coolify instance.+ {$t('register.first_user')}</div>{/if}{/if}diff --git a/static/locales/en.json b/static/locales/en.jsondeleted file mode 100644index f0f095a3b8..0000000000--- a/static/locales/en.json+++ /dev/null@@ -1,16 +0,0 @@-{- "layout": {- "update_done": "Update completed.",- "wait_new_version_startup": "Waiting for the new version to start...",- "new_version": "New version reachable. Reloading...",- "switch_to_a_different_team": "Switch to a different team...",- "update_available": "Update available"- },- "error": {- "you_can_find_your_way_back": "You can find your way back",- "here": "here"- },- "index": {- "dashboard": "Dashboard"- }-}diff --git a/static/locales/fr.json b/static/locales/fr.jsondeleted file mode 100644index 14f19dd475..0000000000--- a/static/locales/fr.json+++ /dev/null@@ -1,5 +0,0 @@-{- "index": {- "dashboard": "Tableau de bord"- }-}diff --git a/svelte.config.js b/svelte.config.jsindex 9d711910bc..4e8bc89664 100644--- a/svelte.config.js+++ b/svelte.config.js@@ -12,12 +12,6 @@ const config = {vite: {optimizeDeps: {exclude: ['svelte-kit-cookie-session']- },- server: {- fs: {- // Allow serving files from one level up to the project root- allow: ['../locales']- }}}}