diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
| commit | b7e39b59fd0fc7b5610ebff29035bf622079e0d8 (patch) | |
| tree | 64be84ebbdac9f7ceced983390c53b10d575af5c /old-apps/web-shared/src/lib/i18n | |
| parent | 2001c035fbb417ab0a3d42cfb04d17420bde4086 (diff) | |
| download | greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.tar.xz greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.zip | |
refactor: Change file structure
Diffstat (limited to 'old-apps/web-shared/src/lib/i18n')
| -rw-r--r-- | old-apps/web-shared/src/lib/i18n/en/index.ts | 18 | ||||
| -rw-r--r-- | old-apps/web-shared/src/lib/i18n/formatters.ts | 11 | ||||
| -rw-r--r-- | old-apps/web-shared/src/lib/i18n/i18n-types.ts | 94 | ||||
| -rw-r--r-- | old-apps/web-shared/src/lib/i18n/i18n-util.async.ts | 27 | ||||
| -rw-r--r-- | old-apps/web-shared/src/lib/i18n/i18n-util.sync.ts | 27 | ||||
| -rw-r--r-- | old-apps/web-shared/src/lib/i18n/i18n-util.ts | 31 | ||||
| -rw-r--r-- | old-apps/web-shared/src/lib/i18n/nb/index.ts | 15 |
7 files changed, 0 insertions, 223 deletions
diff --git a/old-apps/web-shared/src/lib/i18n/en/index.ts b/old-apps/web-shared/src/lib/i18n/en/index.ts deleted file mode 100644 index 9db1759..0000000 --- a/old-apps/web-shared/src/lib/i18n/en/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type {BaseTranslation} from "../i18n-types"; - -const en: BaseTranslation = { - stopwatch: { - roundUp: "Round up", - roundDown: "Round down", - createEntry: "Create entry", - whatsYourFocus: "What's your focus?", - reset: "Reset", - start: "Start", - stop: "Stop", - }, - localeSwitcher: { - language: "Language" - } -}; - -export default en; diff --git a/old-apps/web-shared/src/lib/i18n/formatters.ts b/old-apps/web-shared/src/lib/i18n/formatters.ts deleted file mode 100644 index 78734f9..0000000 --- a/old-apps/web-shared/src/lib/i18n/formatters.ts +++ /dev/null @@ -1,11 +0,0 @@ -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 - } - - return formatters -} diff --git a/old-apps/web-shared/src/lib/i18n/i18n-types.ts b/old-apps/web-shared/src/lib/i18n/i18n-types.ts deleted file mode 100644 index 62a13dd..0000000 --- a/old-apps/web-shared/src/lib/i18n/i18n-types.ts +++ /dev/null @@ -1,94 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ -import type { BaseTranslation as BaseTranslationType, LocalizedString } from 'typesafe-i18n' - -export type BaseTranslation = BaseTranslationType -export type BaseLocale = 'en' - -export type Locales = - | 'en' - | 'nb' - -export type Translation = RootTranslation - -export type Translations = RootTranslation - -type RootTranslation = { - stopwatch: { - /** - * Round up - */ - roundUp: string - /** - * Round down - */ - roundDown: string - /** - * Create entry - */ - createEntry: string - /** - * What's your focus? - */ - whatsYourFocus: string - /** - * Reset - */ - reset: string - /** - * Start - */ - start: string - /** - * Stop - */ - stop: string - } - localeSwitcher: { - /** - * Language - */ - language: string - } -} - -export type TranslationFunctions = { - stopwatch: { - /** - * Round up - */ - roundUp: () => LocalizedString - /** - * Round down - */ - roundDown: () => LocalizedString - /** - * Create entry - */ - createEntry: () => LocalizedString - /** - * What's your focus? - */ - whatsYourFocus: () => LocalizedString - /** - * Reset - */ - reset: () => LocalizedString - /** - * Start - */ - start: () => LocalizedString - /** - * Stop - */ - stop: () => LocalizedString - } - localeSwitcher: { - /** - * Language - */ - language: () => LocalizedString - } -} - -export type Formatters = {} diff --git a/old-apps/web-shared/src/lib/i18n/i18n-util.async.ts b/old-apps/web-shared/src/lib/i18n/i18n-util.async.ts deleted file mode 100644 index 90e55a7..0000000 --- a/old-apps/web-shared/src/lib/i18n/i18n-util.async.ts +++ /dev/null @@ -1,27 +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.js' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' - -const localeTranslationLoaders = { - en: () => import('./en/index.js'), - nb: () => import('./nb/index.js'), -} - -const updateDictionary = (locale: Locales, dictionary: Partial<Translations>) => - loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary } - -export const loadLocaleAsync = async (locale: Locales): Promise<void> => { - updateDictionary( - locale, - (await localeTranslationLoaders[locale]()).default as unknown as Translations - ) - loadFormatters(locale) -} - -export const loadAllLocalesAsync = (): Promise<void[]> => Promise.all(locales.map(loadLocaleAsync)) - -export const loadFormatters = (locale: Locales): void => - void (loadedFormatters[locale] = initFormatters(locale)) diff --git a/old-apps/web-shared/src/lib/i18n/i18n-util.sync.ts b/old-apps/web-shared/src/lib/i18n/i18n-util.sync.ts deleted file mode 100644 index 8909831..0000000 --- a/old-apps/web-shared/src/lib/i18n/i18n-util.sync.ts +++ /dev/null @@ -1,27 +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.js' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' - -import en from './en/index.js' -import nb from './nb/index.js' - -const localeTranslations = { - en, - nb, -} - -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 => { - loadedFormatters[locale] = initFormatters(locale) -} diff --git a/old-apps/web-shared/src/lib/i18n/i18n-util.ts b/old-apps/web-shared/src/lib/i18n/i18n-util.ts deleted file mode 100644 index 5a9dd0d..0000000 --- a/old-apps/web-shared/src/lib/i18n/i18n-util.ts +++ /dev/null @@ -1,31 +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 { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors' -import type { Formatters, Locales, Translations, TranslationFunctions } from './i18n-types.js' - -export const baseLocale: Locales = 'en' - -export const locales: Locales[] = [ - 'en', - 'nb' -] - -export const loadedLocales = {} as Record<Locales, Translations> - -export const loadedFormatters = {} as Record<Locales, Formatters> - -export const i18nString = (locale: Locales) => initI18nString<Locales, Formatters>(locale, loadedFormatters[locale]) - -export const i18nObject = (locale: Locales) => - initI18nObject<Locales, Translations, TranslationFunctions, Formatters>( - locale, - loadedLocales[locale], - loadedFormatters[locale] - ) - -export const i18n = () => initI18n<Locales, Translations, TranslationFunctions, Formatters>(loadedLocales, loadedFormatters) - -export const detectLocale = (...detectors: LocaleDetector[]) => detectLocaleFn<Locales>(baseLocale, locales, ...detectors) diff --git a/old-apps/web-shared/src/lib/i18n/nb/index.ts b/old-apps/web-shared/src/lib/i18n/nb/index.ts deleted file mode 100644 index a1d5f53..0000000 --- a/old-apps/web-shared/src/lib/i18n/nb/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type {Translation} from "../i18n-types"; - -const nb: Translation = { - stopwatch: { - roundUp: "Rund opp", - roundDown: "Rund ned", - createEntry: "Opprett tidsoppføring", - whatsYourFocus: "Hva skal du fokusere på?", - reset: "Tilbakestill", - start: "Start", - stop: "Stopp", - } -}; - -export default nb; |
