Merge branch 'restray_i18n' of https://github.com/restray/coolify into restray-restray_i18n

This commit is contained in:
Andras Bacsai
2022-04-21 09:51:29 +02:00
82 changed files with 1506 additions and 472 deletions

View File

@@ -1,6 +1,7 @@
import { asyncExecShell, getEngine, getUserDetails } from '$lib/common';
import * as db from '$lib/database';
import { ErrorHandler } from '$lib/database';
import { t } from '$lib/translations';
import type { RequestHandler } from '@sveltejs/kit';
export const post: RequestHandler = async (event) => {
@@ -16,7 +17,8 @@ export const post: RequestHandler = async (event) => {
return {
status: found ? 500 : 200,
body: {
error: found && `Domain ${fqdn.replace('www.', '')} is already used.`
error:
found && t.get('application.domain_already_in_use', { domain: fqdn.replace('www.', '') })
}
};
} catch (error) {

View File

@@ -1,6 +1,7 @@
import { getUserDetails } from '$lib/common';
import * as db from '$lib/database';
import { listSettings, ErrorHandler } from '$lib/database';
import { t } from '$lib/translations';
import type { RequestHandler } from '@sveltejs/kit';
import { promises as dns } from 'dns';
@@ -27,7 +28,7 @@ export const del: RequestHandler = async (event) => {
return {
status: 401,
body: {
message: 'You do not have permission to do this. \nAsk an admin to modify your permissions.'
message: t.get('setting.permission_denied')
}
};
if (status === 401) return { status, body };
@@ -44,7 +45,7 @@ export const del: RequestHandler = async (event) => {
return {
status: 200,
body: {
message: 'Domain removed',
message: t.get('setting.domain_removed'),
redirect: ip ? `http://${ip[0]}:3000/settings` : undefined
}
};
@@ -58,7 +59,7 @@ export const post: RequestHandler = async (event) => {
return {
status: 401,
body: {
message: 'You do not have permission to do this. \nAsk an admin to modify your permissions.'
message: t.get('setting.permission_denied')
}
};
if (status === 401) return { status, body };

View File

@@ -36,6 +36,7 @@
import { browser } from '$app/env';
import { getDomain } from '$lib/components/common';
import { toast } from '@zerodevx/svelte-toast';
import { t } from '$lib/translations';
let isRegistrationEnabled = settings.isRegistrationEnabled;
let dualCerts = settings.dualCerts;
@@ -72,7 +73,7 @@
dualCerts = !dualCerts;
}
await post(`/settings.json`, { isRegistrationEnabled, dualCerts });
return toast.push('Settings saved.');
return toast.push(t.get('application.settings_saved'));
} catch ({ error }) {
return errorNotification(error);
}
@@ -99,19 +100,19 @@
</script>
<div class="flex space-x-1 p-6 font-bold">
<div class="mr-4 text-2xl tracking-tight">Settings</div>
<div class="mr-4 text-2xl tracking-tight">{$t('index.settings')}</div>
</div>
{#if $session.teamId === '0'}
<div class="mx-auto max-w-4xl px-6">
<form on:submit|preventDefault={handleSubmit} class="grid grid-flow-row gap-2 py-4">
<div class="flex space-x-1 pb-6">
<div class="title font-bold">Global Settings</div>
<div class="title font-bold">{$t('index.global_settings')}</div>
<button
type="submit"
disabled={loading.save}
class:bg-yellow-500={!loading.save}
class:hover:bg-yellow-400={!loading.save}
class="mx-2 ">{loading.save ? 'Saving...' : 'Save'}</button
class="mx-2 ">{loading.save ? $t('forms.saving') : $t('forms.save')}</button
>
{#if isFqdnSet}
<button
@@ -119,17 +120,17 @@
disabled={loading.remove}
class:bg-red-600={!loading.remove}
class:hover:bg-red-500={!loading.remove}
>{loading.remove ? 'Removing...' : 'Remove domain'}</button
>{loading.remove ? $t('forms.removing') : $t('forms.remove_domain')}</button
>
{/if}
</div>
<div class="grid grid-flow-row gap-2 px-10">
<div class="grid grid-cols-2 items-start">
<div class="flex-col">
<div class="pt-2 text-base font-bold text-stone-100">URL (FQDN)</div>
<Explainer
text="If you specify <span class='text-yellow-500 font-bold'>https</span>, Coolify will be accessible only over https. SSL certificate will be generated for you.<br>If you specify <span class='text-yellow-500 font-bold'>www</span>, Coolify will be redirected (302) from non-www and vice versa."
/>
<div class="pt-2 text-base font-bold text-stone-100">
{$t('application.url_fqdn')}
</div>
<Explainer text={$t('setting.ssl_explainer')} />
</div>
<div class="justify-start text-left">
<input
@@ -139,16 +140,16 @@
name="fqdn"
id="fqdn"
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
placeholder="eg: https://coolify.io"
placeholder="{$t('forms.eg')}: https://coolify.io"
/>
</div>
</div>
<div class="grid grid-cols-2 items-start py-6">
<div class="flex-col">
<div class="pt-2 text-base font-bold text-stone-100">Public Port Range</div>
<Explainer
text="Ports used to expose databases/services/internal services.<br> Add them to your firewall (if applicable).<br><br>You can specify a range of ports, eg: <span class='text-yellow-500 font-bold'>9000-9100</span>"
/>
<div class="pt-2 text-base font-bold text-stone-100">
{$t('forms.public_port_range')}
</div>
<Explainer text={$t('forms.public_port_range_explainer')} />
</div>
<div class="mx-auto flex-row items-center justify-center space-y-2">
<input
@@ -170,40 +171,40 @@
</div>
<div class="grid grid-cols-2 items-center">
<Setting
dataTooltip="Must remove the domain before you can change this setting."
dataTooltip={$t('setting.must_remove_domain_before_changing')}
disabled={isFqdnSet}
bind:setting={dualCerts}
title="Generate SSL for www and non-www?"
description="It will generate certificates for both www and non-www. <br>You need to have <span class='font-bold text-yellow-500'>both DNS entries</span> set in advance.<br><br>Useful if you expect to have visitors on both."
title={$t('application.ssl_www_and_non_www')}
description={$t('services.generate_www_non_www_ssl')}
on:click={() => !isFqdnSet && changeSettings('dualCerts')}
/>
</div>
<div class="grid grid-cols-2 items-center">
<Setting
bind:setting={isRegistrationEnabled}
title="Registration allowed?"
description="Allow further registrations to the application. <br>It's turned off after the first registration. "
title={$t('setting.registration_allowed')}
description={$t('setting.registration_allowed_explainer')}
on:click={() => changeSettings('isRegistrationEnabled')}
/>
</div>
</div>
</form>
<div class="flex space-x-1 pt-6 font-bold">
<div class="title">Coolify Proxy Settings</div>
<div class="title">{$t('setting.coolify_proxy_settings')}</div>
</div>
<Explainer
text={`Credentials for <a class="text-white font-bold" href=${
fqdn
text={$t('setting.credential_stat_explainer', {
link: fqdn
? `http://${settings.proxyUser}:${settings.proxyPassword}@` + getDomain(fqdn) + ':8404'
: browser &&
`http://${settings.proxyUser}:${settings.proxyPassword}@` +
window.location.hostname +
':8404'
} target="_blank">stats</a> page.`}
})}
/>
<div class="space-y-2 px-10 py-5">
<div class="grid grid-cols-2 items-center">
<label for="proxyUser">User</label>
<label for="proxyUser">{$t('forms.user')}</label>
<CopyPasswordField
readonly
disabled
@@ -213,7 +214,7 @@
/>
</div>
<div class="grid grid-cols-2 items-center">
<label for="proxyPassword">Password</label>
<label for="proxyPassword">{$t('forms.password')}</label>
<CopyPasswordField
readonly
disabled