-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76869da
commit 8d9bb3f
Showing
14 changed files
with
252 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
// 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' | ||
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) | ||
const { locale, LL, setLocale } = initI18nSvelte< | ||
Locales, | ||
Translations, | ||
TranslationFunctions, | ||
Formatters | ||
>(loadedLocales, loadedFormatters); | ||
|
||
export { locale, LL, setLocale } | ||
export { locale, LL, setLocale }; | ||
|
||
export default LL | ||
export default LL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,108 @@ | ||
// 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' | ||
import type { | ||
BaseTranslation as BaseTranslationType, | ||
LocalizedString, | ||
RequiredParams, | ||
} from 'typesafe-i18n'; | ||
|
||
export type BaseTranslation = BaseTranslationType | ||
export type BaseLocale = 'en' | ||
export type BaseTranslation = BaseTranslationType; | ||
export type BaseLocale = 'en'; | ||
|
||
export type Locales = | ||
| 'en' | ||
| 'es' | ||
| 'hu' | ||
export type Locales = 'en' | 'es' | 'hu'; | ||
|
||
export type Translation = RootTranslation | ||
export type Translation = RootTranslation; | ||
|
||
export type Translations = RootTranslation | ||
export type Translations = RootTranslation; | ||
|
||
type RootTranslation = { | ||
LAYOUT: { | ||
NAV: { | ||
/** | ||
* Home | ||
*/ | ||
HOME: string | ||
/** | ||
* Notes | ||
*/ | ||
NOTES: string | ||
} | ||
FOOTER: { | ||
/** | ||
* Made with �� and ❤️ by Esteban Borai © {start} - {end} | ||
* @param {number} end | ||
* @param {number} start | ||
*/ | ||
COPYRGHT: RequiredParams<'end' | 'start'> | ||
/** | ||
* Source Code | ||
*/ | ||
SOURCE_CODE: string | ||
} | ||
} | ||
HOMEPAGE: { | ||
/** | ||
* Hey, I'm <span class="font-semibold">{name} {surname}</span>, | ||
* @param {string} name | ||
* @param {string} surname | ||
*/ | ||
HI: RequiredParams<'name' | 'surname'> | ||
/** | ||
* Software Developer with Web & Systems Experience. Favourite language is <span class="hero-emphasis-orange">Rust</span> but I also do <span class="hero-emphasis-blue">TypeScript</span> and <span class="hero-emphasis-red">Svelte</span>. | ||
*/ | ||
ABOUT: string | ||
/** | ||
* Social Networks | ||
*/ | ||
SOCIAL_LINKS: string | ||
/** | ||
* Latest Note | ||
*/ | ||
LATEST_NOTES: string | ||
} | ||
} | ||
LAYOUT: { | ||
NAV: { | ||
/** | ||
* Home | ||
*/ | ||
HOME: string; | ||
/** | ||
* Notes | ||
*/ | ||
NOTES: string; | ||
}; | ||
FOOTER: { | ||
/** | ||
* Made with �� and ❤️ by Esteban Borai © {start} - {end} | ||
* @param {number} end | ||
* @param {number} start | ||
*/ | ||
COPYRGHT: RequiredParams<'end' | 'start'>; | ||
/** | ||
* Source Code | ||
*/ | ||
SOURCE_CODE: string; | ||
}; | ||
}; | ||
HOMEPAGE: { | ||
/** | ||
* Hey, I'm <span class="font-semibold">{name} {surname}</span>, | ||
* @param {string} name | ||
* @param {string} surname | ||
*/ | ||
HI: RequiredParams<'name' | 'surname'>; | ||
/** | ||
* Software Developer with Web & Systems Experience | ||
*/ | ||
ABOUT: string; | ||
/** | ||
* Social Networks | ||
*/ | ||
SOCIAL_LINKS: string; | ||
/** | ||
* Latest Note | ||
*/ | ||
LATEST_NOTES: string; | ||
}; | ||
}; | ||
|
||
export type TranslationFunctions = { | ||
LAYOUT: { | ||
NAV: { | ||
/** | ||
* Home | ||
*/ | ||
HOME: () => LocalizedString | ||
/** | ||
* Notes | ||
*/ | ||
NOTES: () => LocalizedString | ||
} | ||
FOOTER: { | ||
/** | ||
* Made with 🧉 and ❤️ by Esteban Borai © {start} - {end} | ||
*/ | ||
COPYRGHT: (arg: { end: number, start: number }) => LocalizedString | ||
/** | ||
* Source Code | ||
*/ | ||
SOURCE_CODE: () => LocalizedString | ||
} | ||
} | ||
HOMEPAGE: { | ||
/** | ||
* Hey, I'm <span class="font-semibold">{name} {surname}</span>, | ||
*/ | ||
HI: (arg: { name: string, surname: string }) => LocalizedString | ||
/** | ||
* Software Developer with Web & Systems Experience. Favourite language is <span class="hero-emphasis-orange">Rust</span> but I also do <span class="hero-emphasis-blue">TypeScript</span> and <span class="hero-emphasis-red">Svelte</span>. | ||
*/ | ||
ABOUT: () => LocalizedString | ||
/** | ||
* Social Networks | ||
*/ | ||
SOCIAL_LINKS: () => LocalizedString | ||
/** | ||
* Latest Note | ||
*/ | ||
LATEST_NOTES: () => LocalizedString | ||
} | ||
} | ||
LAYOUT: { | ||
NAV: { | ||
/** | ||
* Home | ||
*/ | ||
HOME: () => LocalizedString; | ||
/** | ||
* Notes | ||
*/ | ||
NOTES: () => LocalizedString; | ||
}; | ||
FOOTER: { | ||
/** | ||
* Made with 🧉 and ❤️ by Esteban Borai © {start} - {end} | ||
*/ | ||
COPYRGHT: (arg: { end: number; start: number }) => LocalizedString; | ||
/** | ||
* Source Code | ||
*/ | ||
SOURCE_CODE: () => LocalizedString; | ||
}; | ||
}; | ||
HOMEPAGE: { | ||
/** | ||
* Hey, I'm <span class="font-semibold">{name} {surname}</span>, | ||
*/ | ||
HI: (arg: { name: string; surname: string }) => LocalizedString; | ||
/** | ||
* Software Developer with Web & Systems Experience | ||
*/ | ||
ABOUT: () => LocalizedString; | ||
/** | ||
* Social Networks | ||
*/ | ||
SOCIAL_LINKS: () => LocalizedString; | ||
/** | ||
* Latest Note | ||
*/ | ||
LATEST_NOTES: () => LocalizedString; | ||
}; | ||
}; | ||
|
||
export type Formatters = {} | ||
export type Formatters = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
// 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 { initFormatters } from './formatters'; | ||
import type { Locales, Translations } from './i18n-types'; | ||
import { loadedFormatters, loadedLocales, locales } from './i18n-util'; | ||
|
||
const localeTranslationLoaders = { | ||
en: () => import('./en'), | ||
es: () => import('./es'), | ||
hu: () => import('./hu'), | ||
} | ||
en: () => import('./en'), | ||
es: () => import('./es'), | ||
hu: () => import('./hu'), | ||
}; | ||
|
||
const updateDictionary = (locale: Locales, dictionary: Partial<Translations>): Translations => | ||
loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary } | ||
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 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) | ||
} | ||
updateDictionary(locale, await importLocaleAsync(locale)); | ||
loadFormatters(locale); | ||
}; | ||
|
||
export const loadAllLocalesAsync = (): Promise<void[]> => Promise.all(locales.map(loadLocaleAsync)) | ||
export const loadAllLocalesAsync = (): Promise<void[]> => | ||
Promise.all(locales.map(loadLocaleAsync)); | ||
|
||
export const loadFormatters = (locale: Locales): void => | ||
void (loadedFormatters[locale] = initFormatters(locale)) | ||
void (loadedFormatters[locale] = initFormatters(locale)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
// 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 { initFormatters } from './formatters'; | ||
import type { Locales, Translations } from './i18n-types'; | ||
import { loadedFormatters, loadedLocales, locales } from './i18n-util'; | ||
|
||
import en from './en' | ||
import es from './es' | ||
import hu from './hu' | ||
import en from './en'; | ||
import es from './es'; | ||
import hu from './hu'; | ||
|
||
const localeTranslations = { | ||
en, | ||
es, | ||
hu, | ||
} | ||
en, | ||
es, | ||
hu, | ||
}; | ||
|
||
export const loadLocale = (locale: Locales): void => { | ||
if (loadedLocales[locale]) return | ||
if (loadedLocales[locale]) return; | ||
|
||
loadedLocales[locale] = localeTranslations[locale] as unknown as Translations | ||
loadFormatters(locale) | ||
} | ||
loadedLocales[locale] = localeTranslations[locale] as unknown as Translations; | ||
loadFormatters(locale); | ||
}; | ||
|
||
export const loadAllLocales = (): void => locales.forEach(loadLocale) | ||
export const loadAllLocales = (): void => locales.forEach(loadLocale); | ||
|
||
export const loadFormatters = (locale: Locales): void => | ||
void (loadedFormatters[locale] = initFormatters(locale)) | ||
void (loadedFormatters[locale] = initFormatters(locale)); |
Oops, something went wrong.