aboutsummaryrefslogtreecommitdiffstats
path: root/apps/kit
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-09-29 12:08:43 +0200
committerivarlovlie <git@ivarlovlie.no>2022-09-29 12:08:43 +0200
commit4d6a7e8ba4660f8861de8c8b0f1b45a205b5c738 (patch)
tree4fe4b11a51f18b0fd8a509dc95c224da930915f5 /apps/kit
parenta893be89c5e2863ae44af3fa2c2639604ced1278 (diff)
downloadgreatoffice-4d6a7e8ba4660f8861de8c8b0f1b45a205b5c738.tar.xz
greatoffice-4d6a7e8ba4660f8861de8c8b0f1b45a205b5c738.zip
refactor: Transition back to non-namespaced i18n
Diffstat (limited to 'apps/kit')
-rw-r--r--apps/kit/src/lib/i18n/en/index.ts8
-rw-r--r--apps/kit/src/lib/i18n/en/reset-password/index.ts9
-rw-r--r--apps/kit/src/lib/i18n/en/sign-in/index.ts10
-rw-r--r--apps/kit/src/lib/i18n/en/sign-up/index.ts6
-rw-r--r--apps/kit/src/lib/i18n/i18n-types.ts168
-rw-r--r--apps/kit/src/lib/i18n/i18n-util.async.ts5
-rw-r--r--apps/kit/src/lib/i18n/i18n-util.sync.ts8
-rw-r--r--apps/kit/src/lib/i18n/i18n-util.ts5
-rw-r--r--apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte11
-rw-r--r--apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte10
-rw-r--r--apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte61
-rw-r--r--apps/kit/src/routes/(main)/+layout.ts14
12 files changed, 126 insertions, 189 deletions
diff --git a/apps/kit/src/lib/i18n/en/index.ts b/apps/kit/src/lib/i18n/en/index.ts
index 4c1ad04..5a3ccc8 100644
--- a/apps/kit/src/lib/i18n/en/index.ts
+++ b/apps/kit/src/lib/i18n/en/index.ts
@@ -13,6 +13,14 @@ const en: BaseTranslation = {
success: "Success",
tryAgainSoon: "Try again soon",
unexpectedError: "An unexpected error occured",
+ requestAPasswordReset: "Request a password reset",
+ signIntoYourAccount: "sign into your account",
+ requestSentMessage: "If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account.",
+ signIn: "Sign In",
+ createANewAccount: "create a new account",
+ notMyComputer: "This is not my computer",
+ resetPassword: "Reset password",
+ createYourNewAccount: "Create your new account"
};
export default en;
diff --git a/apps/kit/src/lib/i18n/en/reset-password/index.ts b/apps/kit/src/lib/i18n/en/reset-password/index.ts
deleted file mode 100644
index 00322cf..0000000
--- a/apps/kit/src/lib/i18n/en/reset-password/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import type { BaseTranslation } from "../../i18n-types"
-
-const en_reset_password: BaseTranslation = {
- requestAPasswordReset: "Request a password reset",
- signIntoYourAccount: "sign into your account",
- requestSentMessage: "If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account."
-}
-
-export default en_reset_password \ No newline at end of file
diff --git a/apps/kit/src/lib/i18n/en/sign-in/index.ts b/apps/kit/src/lib/i18n/en/sign-in/index.ts
deleted file mode 100644
index 3c9c104..0000000
--- a/apps/kit/src/lib/i18n/en/sign-in/index.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import type { BaseTranslation } from "../../i18n-types"
-
-const en_sign_in: BaseTranslation = {
- signIn: "Sign In",
- createANewAccount: "create a new account",
- notMyComputer: "This is not my computer",
- resetPassword: "Reset password"
-}
-
-export default en_sign_in \ No newline at end of file
diff --git a/apps/kit/src/lib/i18n/en/sign-up/index.ts b/apps/kit/src/lib/i18n/en/sign-up/index.ts
deleted file mode 100644
index fa0c3d5..0000000
--- a/apps/kit/src/lib/i18n/en/sign-up/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import type { BaseTranslation } from "../../i18n-types"
-
-const en_sign_up: BaseTranslation = {
-}
-
-export default en_sign_up \ No newline at end of file
diff --git a/apps/kit/src/lib/i18n/i18n-types.ts b/apps/kit/src/lib/i18n/i18n-types.ts
index 5139017..3ace345 100644
--- a/apps/kit/src/lib/i18n/i18n-types.ts
+++ b/apps/kit/src/lib/i18n/i18n-types.ts
@@ -12,10 +12,7 @@ export type Translation = RootTranslation & DisallowNamespaces
export type Translations = RootTranslation &
{
- app: NamespaceAppTranslation,
- 'reset-password': NamespaceResetPasswordTranslation,
- 'sign-in': NamespaceSignInTranslation,
- 'sign-up': NamespaceSignUpTranslation
+ app: NamespaceAppTranslation
}
type RootTranslation = {
@@ -28,10 +25,6 @@ type RootTranslation = {
*/
emailAddress: string
/**
- * Request
- */
- request: string
- /**
* Password
*/
password: string
@@ -74,6 +67,38 @@ type RootTranslation = {
* An unexpected error occured
*/
unexpectedError: string
+ /**
+ * Request a password reset
+ */
+ requestAPasswordReset: string
+ /**
+ * sign into your account
+ */
+ signIntoYourAccount: string
+ /**
+ * If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account.
+ */
+ requestSentMessage: string
+ /**
+ * Sign In
+ */
+ signIn: string
+ /**
+ * create a new account
+ */
+ createANewAccount: string
+ /**
+ * This is not my computer
+ */
+ notMyComputer: string
+ /**
+ * Reset password
+ */
+ resetPassword: string
+ /**
+ * Create your new account
+ */
+ createYourNewAccount: string
}
export type NamespaceAppTranslation = {
@@ -387,47 +412,8 @@ export type NamespaceAppTranslation = {
}
}
-export type NamespaceResetPasswordTranslation = {
- /**
- * Request a password reset
- */
- requestAPasswordReset: string
- /**
- * sign into your account
- */
- signIntoYourAccount: string
- /**
- * If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account.
- */
- requestSentMessage: string
-}
-
-export type NamespaceSignInTranslation = {
- /**
- * Sign In
- */
- signIn: string
- /**
- * create a new account
- */
- createANewAccount: string
- /**
- * This is not my computer
- */
- notMyComputer: string
- /**
- * Reset password
- */
- resetPassword: string
-}
-
-export type NamespaceSignUpTranslation = {}
-
export type Namespaces =
| 'app'
- | 'reset-password'
- | 'sign-in'
- | 'sign-up'
type DisallowNamespaces = {
/**
@@ -435,24 +421,6 @@ type DisallowNamespaces = {
* you need to use the `./app/index.ts` file instead
*/
app?: "[typesafe-i18n] reserved for 'app'-namespace. You need to use the `./app/index.ts` file instead."
-
- /**
- * reserved for 'reset-password'-namespace\
- * you need to use the `./reset-password/index.ts` file instead
- */
- 'reset-password'?: "[typesafe-i18n] reserved for 'reset-password'-namespace. You need to use the `./reset-password/index.ts` file instead."
-
- /**
- * reserved for 'sign-in'-namespace\
- * you need to use the `./sign-in/index.ts` file instead
- */
- 'sign-in'?: "[typesafe-i18n] reserved for 'sign-in'-namespace. You need to use the `./sign-in/index.ts` file instead."
-
- /**
- * reserved for 'sign-up'-namespace\
- * you need to use the `./sign-up/index.ts` file instead
- */
- 'sign-up'?: "[typesafe-i18n] reserved for 'sign-up'-namespace. You need to use the `./sign-up/index.ts` file instead."
}
export type TranslationFunctions = {
@@ -465,10 +433,6 @@ export type TranslationFunctions = {
*/
emailAddress: () => LocalizedString
/**
- * Request
- */
- request: () => LocalizedString
- /**
* Password
*/
password: () => LocalizedString
@@ -508,6 +472,38 @@ export type TranslationFunctions = {
* An unexpected error occured
*/
unexpectedError: () => LocalizedString
+ /**
+ * Request a password reset
+ */
+ requestAPasswordReset: () => LocalizedString
+ /**
+ * sign into your account
+ */
+ signIntoYourAccount: () => LocalizedString
+ /**
+ * If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account.
+ */
+ requestSentMessage: () => LocalizedString
+ /**
+ * Sign In
+ */
+ signIn: () => LocalizedString
+ /**
+ * create a new account
+ */
+ createANewAccount: () => LocalizedString
+ /**
+ * This is not my computer
+ */
+ notMyComputer: () => LocalizedString
+ /**
+ * Reset password
+ */
+ resetPassword: () => LocalizedString
+ /**
+ * Create your new account
+ */
+ createYourNewAccount: () => LocalizedString
app: {
nav: {
/**
@@ -814,40 +810,6 @@ export type TranslationFunctions = {
timespan: () => LocalizedString
}
}
- 'reset-password': {
- /**
- * Request a password reset
- */
- requestAPasswordReset: () => LocalizedString
- /**
- * sign into your account
- */
- signIntoYourAccount: () => LocalizedString
- /**
- * If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account.
- */
- requestSentMessage: () => LocalizedString
- }
- 'sign-in': {
- /**
- * Sign In
- */
- signIn: () => LocalizedString
- /**
- * create a new account
- */
- createANewAccount: () => LocalizedString
- /**
- * This is not my computer
- */
- notMyComputer: () => LocalizedString
- /**
- * Reset password
- */
- resetPassword: () => LocalizedString
- }
- 'sign-up': {
- }
}
export type Formatters = {}
diff --git a/apps/kit/src/lib/i18n/i18n-util.async.ts b/apps/kit/src/lib/i18n/i18n-util.async.ts
index a114495..3e8fa1b 100644
--- a/apps/kit/src/lib/i18n/i18n-util.async.ts
+++ b/apps/kit/src/lib/i18n/i18n-util.async.ts
@@ -11,10 +11,7 @@ const localeTranslationLoaders = {
const localeNamespaceLoaders = {
en: {
- app: () => import('./en/app'),
- 'reset-password': () => import('./en/reset-password'),
- 'sign-in': () => import('./en/sign-in'),
- 'sign-up': () => import('./en/sign-up')
+ app: () => import('./en/app')
}
}
diff --git a/apps/kit/src/lib/i18n/i18n-util.sync.ts b/apps/kit/src/lib/i18n/i18n-util.sync.ts
index 15ae633..8f749c7 100644
--- a/apps/kit/src/lib/i18n/i18n-util.sync.ts
+++ b/apps/kit/src/lib/i18n/i18n-util.sync.ts
@@ -8,17 +8,11 @@ import { loadedFormatters, loadedLocales, locales } from './i18n-util'
import en from './en'
import en_app from './en/app'
-import en_reset_password from './en/reset-password'
-import en_sign_in from './en/sign-in'
-import en_sign_up from './en/sign-up'
const localeTranslations = {
en: {
...en,
- app: en_app,
- 'reset-password': en_reset_password,
- 'sign-in': en_sign_in,
- 'sign-up': en_sign_up
+ app: en_app
},
}
diff --git a/apps/kit/src/lib/i18n/i18n-util.ts b/apps/kit/src/lib/i18n/i18n-util.ts
index c4f5c32..09b0155 100644
--- a/apps/kit/src/lib/i18n/i18n-util.ts
+++ b/apps/kit/src/lib/i18n/i18n-util.ts
@@ -13,10 +13,7 @@ export const locales: Locales[] = [
]
export const namespaces: Namespaces[] = [
- 'app',
- 'reset-password',
- 'sign-in',
- 'sign-up'
+ 'app'
]
export const isLocale = (locale: string) => locales.includes(locale as Locales)
diff --git a/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte b/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte
index 865be10..9ee4a83 100644
--- a/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte
+++ b/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte
@@ -17,13 +17,16 @@
title: "",
} as ErrorResult;
+ let loading = false;
let showSuccessAlert = false;
async function submitFormAsync() {
errorData.text = "";
errorData.title = "";
showSuccessAlert = false;
+ loading = true;
const request = await create_forgot_password_request(formData.email);
+ loading = false;
if (!request.ok) {
errorData.text = request.data.text ?? $LL.tryAgainSoon();
errorData.title = request.data.title ?? $LL.unexpectedError();
@@ -38,12 +41,12 @@
<h2
class="mt-6 text-center text-3xl tracking-tight font-bold text-gray-900"
>
- {$LL["reset-password"].requestAPasswordReset()}
+ {$LL.requestAPasswordReset()}
</h2>
<p class="mt-2 text-center text-sm text-gray-600">
- {$LL.or()}
+ {$LL.or().toLowerCase()}
<a href="/sign-in" class="link">
- {$LL["reset-password"].signIntoYourAccount()}
+ {$LL.signIntoYourAccount()}
</a>
</p>
</div>
@@ -61,7 +64,7 @@
<Alert
type="success"
title={$LL.success()}
- message={$LL["reset-password"].requestSentMessage()}
+ message={$LL.requestSentMessage()}
visible={showSuccessAlert}
/>
diff --git a/apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte b/apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte
index d47f924..16d8c3a 100644
--- a/apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte
+++ b/apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte
@@ -39,12 +39,12 @@
<h2
class="mt-6 text-center text-3xl tracking-tight font-bold text-gray-900"
>
- {$LL["sign-in"].signIn()}
+ {$LL.signIn()}
</h2>
<p class="mt-2 text-center text-sm text-gray-600">
{$LL.or().toLowerCase()}
<a href="/sign-up" class="link"
- >{$LL["sign-in"].createANewAccount()}</a
+ >{$LL.createANewAccount()}</a
>
</p>
</div>
@@ -88,17 +88,17 @@
<Checkbox
id="remember-me"
name="remember-me"
- label={$LL["sign-in"].notMyComputer()}
+ label={$LL.notMyComputer()}
/>
<div class="text-sm">
<a href="/reset-password" class="link">
- {$LL["sign-in"].resetPassword()}
+ {$LL.resetPassword()}
</a>
</div>
</div>
<Button
- text={$LL["sign-in"].signIn()}
+ text={$LL.signIn()}
fullWidth
type="submit"
{loading}
diff --git a/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte b/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte
index 92ebfbd..8b89190 100644
--- a/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte
+++ b/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte
@@ -1,37 +1,48 @@
+<script>
+ import { Button, Input } from "$lib/components";
+ import LL from "$lib/i18n/i18n-svelte";
+
+ const formData = {
+ emailAddress: "",
+ password: "",
+ };
+</script>
+
<div class="min-h-full flex flex-col justify-center py-12 sm:px-6 lg:px-8">
<div class="sm:mx-auto sm:w-full sm:max-w-md">
- <h2 class="mt-6 text-center text-3xl tracking-tight font-bold text-gray-900">Create your new account</h2>
+ <h2
+ class="mt-6 text-center text-3xl tracking-tight font-bold text-gray-900"
+ >
+ {$LL.createYourNewAccount()}
+ </h2>
<p class="mt-2 text-center text-sm text-gray-600">
- Or
- <a href="/sign-in" class="font-medium text-indigo-600 hover:text-indigo-500">sign into an existing one</a>
+ {$LL.or().toLowerCase()}
+ <a href="/sign-in" class="link">{$LL.signIntoYourAccount()}</a>
</p>
</div>
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
- <form class="space-y-6" action="#" method="POST">
- <div>
- <label for="email" class="block text-sm font-medium text-gray-700"> Email address </label>
- <div class="mt-1">
- <input id="email" name="email" type="email" autocomplete="email" required
- class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
- </div>
- </div>
-
- <div>
- <label for="password" class="block text-sm font-medium text-gray-700"> Password </label>
- <div class="mt-1">
- <input id="password" name="password" type="password" autocomplete="current-password" required
- class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
- </div>
- </div>
+ <form class="space-y-6" action="#">
+ <Input
+ label={$LL.emailAddress()}
+ id="email"
+ name="email"
+ autocomplete="email"
+ required
+ type="email"
+ bind:value={formData.emailAddress}
+ />
- <div>
- <button type="submit"
- class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
- Create account
- </button>
- </div>
+ <Input
+ label={$LL.password()}
+ id="password"
+ name="password"
+ required
+ type="password"
+ bind:value={formData.password}
+ />
+ <Button type="submit" text={$LL.submit()} fullWidth />
</form>
</div>
</div>
diff --git a/apps/kit/src/routes/(main)/+layout.ts b/apps/kit/src/routes/(main)/+layout.ts
index f673067..13837be 100644
--- a/apps/kit/src/routes/(main)/+layout.ts
+++ b/apps/kit/src/routes/(main)/+layout.ts
@@ -1,19 +1,9 @@
import type { Locales } from "$lib/i18n/i18n-types";
-import { loadLocaleAsync, loadNamespaceAsync } from "$lib/i18n/i18n-util.async";
+import { loadLocaleAsync } from "$lib/i18n/i18n-util.async";
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad<{ locale: Locales }> = async ({ url, params }) => {
let lang = "en" as Locales;
await loadLocaleAsync(lang);
-
- if (url.pathname.startsWith("/sign-in")) {
- await loadNamespaceAsync(lang, "sign-in");
- }
- if (url.pathname.startsWith("/sign-up")) {
- await loadNamespaceAsync(lang, "sign-up");
- }
- if (url.pathname.startsWith("/reset-password")) {
- await loadNamespaceAsync(lang, "reset-password");
- }
return { locale: lang };
-}; \ No newline at end of file
+};