From a53bda1436742db449ad7763563ca15775b1ee00 Mon Sep 17 00:00:00 2001 From: Restray Date: Sat, 2 Apr 2022 23:34:30 +0200 Subject: [PATCH] Add destinations i18n --- src/lib/locales/en.json | 21 ++++++++++-- src/routes/destinations/[id]/_FoundApp.svelte | 9 ++--- .../destinations/[id]/_LocalDocker.svelte | 33 ++++++++++--------- .../destinations/[id]/_RemoteDocker.svelte | 33 ++++++++++--------- src/routes/destinations/[id]/__layout.svelte | 9 ++--- src/routes/destinations/[id]/index.svelte | 3 +- src/routes/destinations/index.svelte | 6 ++-- 7 files changed, 69 insertions(+), 45 deletions(-) diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json index 3b0ff03fd..0d65578b4 100644 --- a/src/lib/locales/en.json +++ b/src/lib/locales/en.json @@ -31,7 +31,7 @@ "password_again": "Password again", "save": "Save", "saving": "Saving...", - "name": "Name", + "name": "name", "value": "Value", "action": "Action", "is_required": "is required.", @@ -52,7 +52,11 @@ "user": "User", "loading": "Loading...", "version": "Version", - "host": "Host" + "host": "Host", + "already_used_for": "{type} already used for", + "configuration": "Configuration", + "engine": "Engine", + "network": "Network" }, "register": { "register": "Register", @@ -182,5 +186,18 @@ "delete_database": "Delete Database", "permission_denied_delete_database": "You do not have permission to delete a Database", "no_databases_found": "No databases found" + }, + "destination": { + "delete_destination": "Delete Destination", + "permission_denied_delete_destination": "You do not have permission to delete this destination", + "add_to_coolify": "Add to Coolify", + "coolify_proxy_stopped": "Coolify Proxy stopped!", + "coolify_proxy_started": "Coolify Proxy started!", + "confirm_restart_proxy": "Are you sure you want to restart the proxy? Everything will be reconfigured in ~10 secs.", + "coolify_proxy_restarting": "Coolify Proxy restarting...", + "restarting_please_wait": "Restarting... please wait...", + "force_restart_proxy": "Force restart proxy", + "use_coolify_proxy": "Use Coolify Proxy?", + "no_destination_found": "No destination found" } } diff --git a/src/routes/destinations/[id]/_FoundApp.svelte b/src/routes/destinations/[id]/_FoundApp.svelte index 835c121bf..f6c44bb25 100644 --- a/src/routes/destinations/[id]/_FoundApp.svelte +++ b/src/routes/destinations/[id]/_FoundApp.svelte @@ -2,6 +2,7 @@ export let app; import { onMount } from 'svelte'; import { page } from '$app/stores'; + import { t } from '$lib/translations'; const { id } = $page.params; let loading = true; async function checkApp() { @@ -58,20 +59,20 @@
{app.domain}
{#if loading} -
Loading...
+
{$t('forms.loading')}
{:else if app.foundByDomain}
- Domain already used for + {@html $t('forms.already_used_for', { type: 'Domains' })} {app.foundName}
{:else if app.foundByRepository}
- Repository already used for + {@html $t('forms.already_used_for', { type: 'Repository' })} {app.foundName}
{:else} {$t('destination.add_to_coolify')} {/if}
diff --git a/src/routes/destinations/[id]/_LocalDocker.svelte b/src/routes/destinations/[id]/_LocalDocker.svelte index 329d23c2f..4ee6195e0 100644 --- a/src/routes/destinations/[id]/_LocalDocker.svelte +++ b/src/routes/destinations/[id]/_LocalDocker.svelte @@ -10,6 +10,7 @@ import { post } from '$lib/api'; import CopyPasswordField from '$lib/components/CopyPasswordField.svelte'; import { onMount } from 'svelte'; + import { t } from '$lib/translations'; const { id } = $page.params; let cannotDisable = settings.fqdn && destination.engine === '/var/run/docker.sock'; // let scannedApps = []; @@ -88,7 +89,7 @@ async function stopProxy() { try { await post(`/destinations/${id}/stop.json`, { engine: destination.engine }); - return toast.push('Coolify Proxy stopped!'); + return toast.push($t('destination.coolify_proxy_stopped')); } catch ({ error }) { return errorNotification(error); } @@ -96,19 +97,17 @@ async function startProxy() { try { await post(`/destinations/${id}/start.json`, { engine: destination.engine }); - return toast.push('Coolify Proxy started!'); + return toast.push($t('destination.coolify_proxy_started')); } catch ({ error }) { return errorNotification(error); } } async function forceRestartProxy() { - const sure = confirm( - 'Are you sure you want to restart the proxy? Everything will be reconfigured in ~10 secs.' - ); + const sure = confirm($t('destination.confirm_restart_proxy')); if (sure) { try { restarting = true; - toast.push('Coolify Proxy restarting...'); + toast.push($t('destination.coolify_proxy_restarting')); await post(`/destinations/${id}/restart.json`, { engine: destination.engine, fqdn: settings.fqdn @@ -126,7 +125,7 @@
-
Configuration
+
{$t('forms.configuration')}
{#if $session.isAdmin} {restarting + ? $t('destination.restarting_please_wait') + : $t('destination.force_restart_proxy')} {/if}
- +
- +
@@ -174,13 +175,13 @@
-->
- +
@@ -189,7 +190,7 @@ disabled={cannotDisable} bind:setting={destination.isCoolifyProxyUsed} on:click={changeProxySetting} - title="Use Coolify Proxy?" + title={$t('destination.use_coolify_proxy')} description={`This will install a proxy on the destination to allow you to access your applications and services without any manual configuration. Databases will have their own proxy.

${ cannotDisable ? 'You cannot disable this proxy as FQDN is configured for Coolify.' diff --git a/src/routes/destinations/[id]/_RemoteDocker.svelte b/src/routes/destinations/[id]/_RemoteDocker.svelte index 4de1b82ce..c17d0239b 100644 --- a/src/routes/destinations/[id]/_RemoteDocker.svelte +++ b/src/routes/destinations/[id]/_RemoteDocker.svelte @@ -11,6 +11,7 @@ import CopyPasswordField from '$lib/components/CopyPasswordField.svelte'; import { onMount } from 'svelte'; import { generateRemoteEngine } from '$lib/components/common'; + import { t } from '$lib/translations'; const { id } = $page.params; let cannotDisable = settings.fqdn && destination.engine === '/var/run/docker.sock'; // let scannedApps = []; @@ -90,7 +91,7 @@ try { const engine = generateRemoteEngine(destination); await post(`/destinations/${id}/stop.json`, { engine }); - return toast.push('Coolify Proxy stopped!'); + return toast.push($t('destination.coolify_proxy_stopped')); } catch ({ error }) { return errorNotification(error); } @@ -99,19 +100,17 @@ try { const engine = generateRemoteEngine(destination); await post(`/destinations/${id}/start.json`, { engine }); - return toast.push('Coolify Proxy started!'); + return toast.push($t('destination.coolify_proxy_started')); } catch ({ error }) { return errorNotification(error); } } async function forceRestartProxy() { - const sure = confirm( - 'Are you sure you want to restart the proxy? Everything will be reconfigured in ~10 secs.' - ); + const sure = confirm($t('destination.confirm_restart_proxy')); if (sure) { try { restarting = true; - toast.push('Coolify Proxy restarting...'); + toast.push($t('destination.coolify_proxy_restarting')); await post(`/destinations/${id}/restart.json`, { engine: destination.engine, fqdn: settings.fqdn @@ -127,7 +126,7 @@
-
Configuration
+
{$t('forms.configuration')}
{#if $session.isAdmin} {restarting + ? $t('destination.restarting_please_wait') + : $t('destination.force_restart_proxy')} {/if}
- +
- +
@@ -175,13 +176,13 @@
-->
- +
@@ -190,7 +191,7 @@ disabled={cannotDisable} bind:setting={destination.isCoolifyProxyUsed} on:click={changeProxySetting} - title="Use Coolify Proxy?" + title={$t('destination.use_coolify_proxy')} description={`This will install a proxy on the destination to allow you to access your applications and services without any manual configuration. Databases will have their own proxy.

${ cannotDisable ? 'You cannot disable this proxy as FQDN is configured for Coolify.' diff --git a/src/routes/destinations/[id]/__layout.svelte b/src/routes/destinations/[id]/__layout.svelte index 892e8e99b..6d49fbb63 100644 --- a/src/routes/destinations/[id]/__layout.svelte +++ b/src/routes/destinations/[id]/__layout.svelte @@ -37,10 +37,11 @@ import DeleteIcon from '$lib/components/DeleteIcon.svelte'; import { del } from '$lib/api'; import { goto } from '$app/navigation'; + import { t } from '$lib/translations'; export let destination; async function deleteDestination(destination) { - const sure = confirm(`Are you sure you would like to delete '${destination.name}'?`); + const sure = confirm($t('application.confirm_to_delete', { name: destination.name })); if (sure) { try { await del(`/destinations/${destination.id}.json`, { id: destination.id }); @@ -55,14 +56,14 @@ diff --git a/src/routes/destinations/[id]/index.svelte b/src/routes/destinations/[id]/index.svelte index 68f529b54..1effefdd7 100644 --- a/src/routes/destinations/[id]/index.svelte +++ b/src/routes/destinations/[id]/index.svelte @@ -36,10 +36,11 @@ import type Prisma from '@prisma/client'; import LocalDocker from './_LocalDocker.svelte'; import RemoteDocker from './_RemoteDocker.svelte'; + import { t } from '$lib/translations';
-
Destination
+
{$t('application.destination')}
> {destination.name}
diff --git a/src/routes/destinations/index.svelte b/src/routes/destinations/index.svelte index 01f860b21..e610777c0 100644 --- a/src/routes/destinations/index.svelte +++ b/src/routes/destinations/index.svelte @@ -23,11 +23,13 @@ import type Prisma from '@prisma/client'; import { session } from '$app/stores'; + import { t } from '$lib/translations'; + export let destinations: Prisma.DestinationDocker[];