diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-09 03:57:12 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-09 03:57:12 +0100 |
| commit | 4dbef3fcd7a14437d55c555cf10d50de8e50d7d1 (patch) | |
| tree | 632589ecfcfb4dfddeafb71d0077257584b5e7ec /code/app/src/lib/i18n | |
| parent | 914c75e0ceeb3e11ddd55e94bb461c26b0db5b7a (diff) | |
| download | greatoffice-4dbef3fcd7a14437d55c555cf10d50de8e50d7d1.tar.xz greatoffice-4dbef3fcd7a14437d55c555cf10d50de8e50d7d1.zip | |
feat: Move everything out of $lib
Diffstat (limited to 'code/app/src/lib/i18n')
| -rw-r--r-- | code/app/src/lib/i18n/en/app/index.ts | 7 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/en/index.ts | 59 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/formatters.ts | 13 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/i18n-svelte.ts | 12 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/i18n-types.ts | 429 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/i18n-util.async.ts | 42 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/i18n-util.sync.ts | 35 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/i18n-util.ts | 41 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/nb/app/index.ts | 7 | ||||
| -rw-r--r-- | code/app/src/lib/i18n/nb/index.ts | 51 |
10 files changed, 0 insertions, 696 deletions
diff --git a/code/app/src/lib/i18n/en/app/index.ts b/code/app/src/lib/i18n/en/app/index.ts deleted file mode 100644 index 7ccfc97..0000000 --- a/code/app/src/lib/i18n/en/app/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { BaseTranslation } from '../../i18n-types' - -const en_app: BaseTranslation = { - members: "Members", -} - -export default en_app
\ No newline at end of file diff --git a/code/app/src/lib/i18n/en/index.ts b/code/app/src/lib/i18n/en/index.ts deleted file mode 100644 index fbf5423..0000000 --- a/code/app/src/lib/i18n/en/index.ts +++ /dev/null @@ -1,59 +0,0 @@ -import type { BaseTranslation } from "../i18n-types"; - -const en: BaseTranslation = { - or: "Or", - name: "Name", - emailAddress: "Email address", - password: "Password", - pageNotFound: "Page not found", - noInternet: "It seems like your device does not have a internet connection, please check your connection.", - reset: "Reset", - of: "{0} of {1}", - isRequired: "{0} is required", - submit: "Submit", - success: "Success", - tryAgainSoon: "Try again soon", - createANewAccount: "Create a new account", - unexpectedError: "An unexpected error occured", - notFound: "Not found", - documentation: "Documentation", - tos: "Terms of service", - privacyPolicy: "Privacy policy", - signIntoYourAccount: "Sign into your account", - combobox: { - search: "Search", - noRecordsFound: "No records found", - createRecordHelpText: "Create a record by typing the name in the search bar and pressing enter", - createRecordButtonText: "Press enter or click here to create {0}" - }, - signInPage: { - notMyComputer: "This is not my computer", - resetPassword: "Reset password", - yourPasswordIsUpdated: "Your password is updated", - signIn: "Sign In", - yourNewPasswordIsApplied: "Your new password is applied", - signInBelow: "Sign in below", - yourAccountIsDisabled: "Your account is disabled", - contactYourAdminIfDisabled: "Contact your administrator if this feels wrong", - youHaveReachedInactivityLimit: "You've reached the hidden inactivity limit", - feelFreeToSignInAgain: "Feel free to sign in again" - }, - signUpPage: { - createYourNewAccount: "Create your new account", - }, - resetPasswordPage: { - setANewPassword: "Set a new password", - expired: "Expired", - requestHasExpired: "Your request has expired", - requestANewReset: "Request a new reset", - invalidRequestTitle: "Your request is invalid", - invalidRequestMessage: "This could be due to it being expired, nonexsistent or something else", - newPassword: "New password", - 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.", - requestAPasswordReset: "Request a password reset", - requestNotFound: "Your request was not found", - submitANewRequestBelow: "Submit a new reset request below" - } -}; - -export default en; diff --git a/code/app/src/lib/i18n/formatters.ts b/code/app/src/lib/i18n/formatters.ts deleted file mode 100644 index 5232b7d..0000000 --- a/code/app/src/lib/i18n/formatters.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { capitalise } from '$lib/helpers' -import type { FormattersInitializer } from 'typesafe-i18n' -import type { Locales, Formatters } from './i18n-types' - -export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => { - - const formatters: Formatters = { - // add your formatter functions here - capitalise: (value: string) => capitalise(value) - } - - return formatters -} diff --git a/code/app/src/lib/i18n/i18n-svelte.ts b/code/app/src/lib/i18n/i18n-svelte.ts deleted file mode 100644 index 6cdffb3..0000000 --- a/code/app/src/lib/i18n/i18n-svelte.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { initI18nSvelte } from 'typesafe-i18n/svelte' -import type { Formatters, Locales, TranslationFunctions, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales } from './i18n-util' - -const { locale, LL, setLocale } = initI18nSvelte<Locales, Translations, TranslationFunctions, Formatters>(loadedLocales, loadedFormatters) - -export { locale, LL, setLocale } - -export default LL diff --git a/code/app/src/lib/i18n/i18n-types.ts b/code/app/src/lib/i18n/i18n-types.ts deleted file mode 100644 index cf968d7..0000000 --- a/code/app/src/lib/i18n/i18n-types.ts +++ /dev/null @@ -1,429 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ -import type { BaseTranslation as BaseTranslationType, LocalizedString, RequiredParams } from 'typesafe-i18n' - -export type BaseTranslation = BaseTranslationType & DisallowNamespaces -export type BaseLocale = 'en' - -export type Locales = - | 'en' - | 'nb' - -export type Translation = RootTranslation & DisallowNamespaces - -export type Translations = RootTranslation & -{ - app: NamespaceAppTranslation -} - -type RootTranslation = { - /** - * Or - */ - or: string - /** - * Name - */ - name: string - /** - * Email address - */ - emailAddress: string - /** - * Password - */ - password: string - /** - * Page not found - */ - pageNotFound: string - /** - * It seems like your device does not have a internet connection, please check your connection. - */ - noInternet: string - /** - * Reset - */ - reset: string - /** - * {0} of {1} - * @param {unknown} 0 - * @param {unknown} 1 - */ - of: RequiredParams<'0' | '1'> - /** - * {0} is required - * @param {unknown} 0 - */ - isRequired: RequiredParams<'0'> - /** - * Submit - */ - submit: string - /** - * Success - */ - success: string - /** - * Try again soon - */ - tryAgainSoon: string - /** - * Create a new account - */ - createANewAccount: string - /** - * An unexpected error occured - */ - unexpectedError: string - /** - * Not found - */ - notFound: string - /** - * Documentation - */ - documentation: string - /** - * Terms of service - */ - tos: string - /** - * Privacy policy - */ - privacyPolicy: string - /** - * Sign into your account - */ - signIntoYourAccount: string - combobox: { - /** - * Search - */ - search: string - /** - * No records found - */ - noRecordsFound: string - /** - * Create a record by typing the name in the search bar and pressing enter - */ - createRecordHelpText: string - /** - * Press enter or click here to create {0} - * @param {unknown} 0 - */ - createRecordButtonText: RequiredParams<'0'> - } - signInPage: { - /** - * This is not my computer - */ - notMyComputer: string - /** - * Reset password - */ - resetPassword: string - /** - * Your password is updated - */ - yourPasswordIsUpdated: string - /** - * Sign In - */ - signIn: string - /** - * Your new password is applied - */ - yourNewPasswordIsApplied: string - /** - * Sign in below - */ - signInBelow: string - /** - * Your account is disabled - */ - yourAccountIsDisabled: string - /** - * Contact your administrator if this feels wrong - */ - contactYourAdminIfDisabled: string - /** - * You've reached the hidden inactivity limit - */ - youHaveReachedInactivityLimit: string - /** - * Feel free to sign in again - */ - feelFreeToSignInAgain: string - } - signUpPage: { - /** - * Create your new account - */ - createYourNewAccount: string - } - resetPasswordPage: { - /** - * Set a new password - */ - setANewPassword: string - /** - * Expired - */ - expired: string - /** - * Your request has expired - */ - requestHasExpired: string - /** - * Request a new reset - */ - requestANewReset: string - /** - * Your request is invalid - */ - invalidRequestTitle: string - /** - * This could be due to it being expired, nonexsistent or something else - */ - invalidRequestMessage: string - /** - * New password - */ - newPassword: 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 - /** - * Request a password reset - */ - requestAPasswordReset: string - /** - * Your request was not found - */ - requestNotFound: string - /** - * Submit a new reset request below - */ - submitANewRequestBelow: string - } -} - -export type NamespaceAppTranslation = { - /** - * Members - */ - members: string -} - -export type Namespaces = - | 'app' - -type DisallowNamespaces = { - /** - * reserved for 'app'-namespace\ - * 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." -} - -export type TranslationFunctions = { - /** - * Or - */ - or: () => LocalizedString - /** - * Name - */ - name: () => LocalizedString - /** - * Email address - */ - emailAddress: () => LocalizedString - /** - * Password - */ - password: () => LocalizedString - /** - * Page not found - */ - pageNotFound: () => LocalizedString - /** - * It seems like your device does not have a internet connection, please check your connection. - */ - noInternet: () => LocalizedString - /** - * Reset - */ - reset: () => LocalizedString - /** - * {0} of {1} - */ - of: (arg0: unknown, arg1: unknown) => LocalizedString - /** - * {0} is required - */ - isRequired: (arg0: unknown) => LocalizedString - /** - * Submit - */ - submit: () => LocalizedString - /** - * Success - */ - success: () => LocalizedString - /** - * Try again soon - */ - tryAgainSoon: () => LocalizedString - /** - * Create a new account - */ - createANewAccount: () => LocalizedString - /** - * An unexpected error occured - */ - unexpectedError: () => LocalizedString - /** - * Not found - */ - notFound: () => LocalizedString - /** - * Documentation - */ - documentation: () => LocalizedString - /** - * Terms of service - */ - tos: () => LocalizedString - /** - * Privacy policy - */ - privacyPolicy: () => LocalizedString - /** - * Sign into your account - */ - signIntoYourAccount: () => LocalizedString - combobox: { - /** - * Search - */ - search: () => LocalizedString - /** - * No records found - */ - noRecordsFound: () => LocalizedString - /** - * Create a record by typing the name in the search bar and pressing enter - */ - createRecordHelpText: () => LocalizedString - /** - * Press enter or click here to create {0} - */ - createRecordButtonText: (arg0: unknown) => LocalizedString - } - signInPage: { - /** - * This is not my computer - */ - notMyComputer: () => LocalizedString - /** - * Reset password - */ - resetPassword: () => LocalizedString - /** - * Your password is updated - */ - yourPasswordIsUpdated: () => LocalizedString - /** - * Sign In - */ - signIn: () => LocalizedString - /** - * Your new password is applied - */ - yourNewPasswordIsApplied: () => LocalizedString - /** - * Sign in below - */ - signInBelow: () => LocalizedString - /** - * Your account is disabled - */ - yourAccountIsDisabled: () => LocalizedString - /** - * Contact your administrator if this feels wrong - */ - contactYourAdminIfDisabled: () => LocalizedString - /** - * You've reached the hidden inactivity limit - */ - youHaveReachedInactivityLimit: () => LocalizedString - /** - * Feel free to sign in again - */ - feelFreeToSignInAgain: () => LocalizedString - } - signUpPage: { - /** - * Create your new account - */ - createYourNewAccount: () => LocalizedString - } - resetPasswordPage: { - /** - * Set a new password - */ - setANewPassword: () => LocalizedString - /** - * Expired - */ - expired: () => LocalizedString - /** - * Your request has expired - */ - requestHasExpired: () => LocalizedString - /** - * Request a new reset - */ - requestANewReset: () => LocalizedString - /** - * Your request is invalid - */ - invalidRequestTitle: () => LocalizedString - /** - * This could be due to it being expired, nonexsistent or something else - */ - invalidRequestMessage: () => LocalizedString - /** - * New password - */ - newPassword: () => 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 - /** - * Request a password reset - */ - requestAPasswordReset: () => LocalizedString - /** - * Your request was not found - */ - requestNotFound: () => LocalizedString - /** - * Submit a new reset request below - */ - submitANewRequestBelow: () => LocalizedString - } - app: { - /** - * Members - */ - members: () => LocalizedString - } -} - -export type Formatters = {} diff --git a/code/app/src/lib/i18n/i18n-util.async.ts b/code/app/src/lib/i18n/i18n-util.async.ts deleted file mode 100644 index 2e6717e..0000000 --- a/code/app/src/lib/i18n/i18n-util.async.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { initFormatters } from './formatters' -import type { Locales, Namespaces, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' - -const localeTranslationLoaders = { - en: () => import('./en'), - nb: () => import('./nb'), -} - -const localeNamespaceLoaders = { - en: { - app: () => import('./en/app') - }, - nb: { - app: () => import('./nb/app') - } -} - -const updateDictionary = (locale: Locales, dictionary: Partial<Translations>): Translations => - loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary } - -export const importLocaleAsync = async (locale: Locales): Promise<Translations> => - (await localeTranslationLoaders[locale]()).default as unknown as Translations - -export const loadLocaleAsync = async (locale: Locales): Promise<void> => { - updateDictionary(locale, await importLocaleAsync(locale)) - loadFormatters(locale) -} - -export const loadAllLocalesAsync = (): Promise<void[]> => Promise.all(locales.map(loadLocaleAsync)) - -export const loadFormatters = (locale: Locales): void => - void (loadedFormatters[locale] = initFormatters(locale)) - -export const importNamespaceAsync = async<Namespace extends Namespaces>(locale: Locales, namespace: Namespace) => - (await localeNamespaceLoaders[locale][namespace]()).default as unknown as Translations[Namespace] - -export const loadNamespaceAsync = async <Namespace extends Namespaces>(locale: Locales, namespace: Namespace): Promise<void> => - void updateDictionary(locale, { [namespace]: await importNamespaceAsync(locale, namespace )}) diff --git a/code/app/src/lib/i18n/i18n-util.sync.ts b/code/app/src/lib/i18n/i18n-util.sync.ts deleted file mode 100644 index 8144fdc..0000000 --- a/code/app/src/lib/i18n/i18n-util.sync.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { initFormatters } from './formatters' -import type { Locales, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' - -import en from './en' -import nb from './nb' - -import en_app from './en/app' -import nb_app from './nb/app' - -const localeTranslations = { - en: { - ...en, - app: en_app - }, - nb: { - ...nb, - app: nb_app - }, -} - -export const loadLocale = (locale: Locales): void => { - if (loadedLocales[locale]) return - - loadedLocales[locale] = localeTranslations[locale] as unknown as Translations - loadFormatters(locale) -} - -export const loadAllLocales = (): void => locales.forEach(loadLocale) - -export const loadFormatters = (locale: Locales): void => - void (loadedFormatters[locale] = initFormatters(locale)) diff --git a/code/app/src/lib/i18n/i18n-util.ts b/code/app/src/lib/i18n/i18n-util.ts deleted file mode 100644 index 12feb33..0000000 --- a/code/app/src/lib/i18n/i18n-util.ts +++ /dev/null @@ -1,41 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { i18n as initI18n, i18nObject as initI18nObject, i18nString as initI18nString } from 'typesafe-i18n' -import type { LocaleDetector } from 'typesafe-i18n/detectors' -import type { LocaleTranslationFunctions, TranslateByString } from 'typesafe-i18n' -import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors' -import type { Formatters, Locales, Namespaces, Translations, TranslationFunctions } from './i18n-types' - -export const baseLocale: Locales = 'en' - -export const locales: Locales[] = [ - 'en', - 'nb' -] - -export const namespaces: Namespaces[] = [ - 'app' -] - -export const isLocale = (locale: string): locale is Locales => locales.includes(locale as Locales) - -export const isNamespace = (namespace: string): namespace is Namespaces => namespaces.includes(namespace as Namespaces) - -export const loadedLocales: Record<Locales, Translations> = {} as Record<Locales, Translations> - -export const loadedFormatters: Record<Locales, Formatters> = {} as Record<Locales, Formatters> - -export const i18nString = (locale: Locales): TranslateByString => initI18nString<Locales, Formatters>(locale, loadedFormatters[locale]) - -export const i18nObject = (locale: Locales): TranslationFunctions => - initI18nObject<Locales, Translations, TranslationFunctions, Formatters>( - locale, - loadedLocales[locale], - loadedFormatters[locale] - ) - -export const i18n = (): LocaleTranslationFunctions<Locales, Translations, TranslationFunctions> => - initI18n<Locales, Translations, TranslationFunctions, Formatters>(loadedLocales, loadedFormatters) - -export const detectLocale = (...detectors: LocaleDetector[]): Locales => detectLocaleFn<Locales>(baseLocale, locales, ...detectors) diff --git a/code/app/src/lib/i18n/nb/app/index.ts b/code/app/src/lib/i18n/nb/app/index.ts deleted file mode 100644 index 6bf9ba6..0000000 --- a/code/app/src/lib/i18n/nb/app/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { NamespaceAppTranslation } from '../../i18n-types' - -const nb_app: NamespaceAppTranslation = { - members: "Medlemmer" -} - -export default nb_app diff --git a/code/app/src/lib/i18n/nb/index.ts b/code/app/src/lib/i18n/nb/index.ts deleted file mode 100644 index ef67504..0000000 --- a/code/app/src/lib/i18n/nb/index.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { Translation } from "../i18n-types"; - -const nb: Translation = { - or: "Eller", - name: "Navn", - emailAddress: "E-postadresse", - password: "Passord", - pageNotFound: "Fant ikke siden", - noInternet: "Det ser ut som at du ikke tilkoblet internettet, sjekk tilkoblingen din for å fortsette", - reset: "Tilbakestill", - of: "{0} av {1}", - isRequired: "{0} er påkrevd", - submit: "Send", - success: "Suksess", - tryAgainSoon: "Prøv igjen snart", - createANewAccount: "Lag en ny konto", - unexpectedError: "En uventet feil oppstod", - notFound: "Ikke funnet", - documentation: "Dokumentasjon", - tos: "Vilkår", - privacyPolicy: "Personvernerklæring", - signIntoYourAccount: "Logg inn med din konto", - signInPage: { - notMyComputer: "Dette er ikke min datamaskin", - resetPassword: "Tilbakestill passord", - yourPasswordIsUpdated: "Ditt passord er oppdater", - signIn: "Logg inn", - yourNewPasswordIsApplied: "Ditt nye passord er satt", - signInBelow: "Logg inn nedenfor", - yourAccountIsDisabled: "Din konto er deaktivert", - contactYourAdminIfDisabled: "Ta kontakt med din administrator hvis dette føles feil", - youHaveReachedInactivityLimit: "Du har nådd den hemmelige inaktivitetsgrensen", - feelFreeToSignInAgain: "Logg gjerne inn igjen" - }, - signUpPage: { - createYourNewAccount: "Opprett din nye konto", - }, - resetPasswordPage: { - setANewPassword: "Skriv et nytt passord", - expired: "Utgått", - requestHasExpired: "Din forespørsel er utgått", - requestANewReset: "Spør om en ny tilbakestillingslenke", - newPassword: "Nytt passord", - requestSentMessage: "Hvis vi finner e-postadressen din i våre systemer, vil du få en e-post med instrukser for å sette ditt nye passord.", - requestAPasswordReset: "Forespør tilbakestilling av ditt passord", - requestNotFound: "Din forespørsel ble ikke funnet", - submitANewRequestBelow: "Spør om en ny tilbakestillingslenke nedenfor" - } -} - -export default nb;
\ No newline at end of file |
