diff --git a/packages/i18n/src/index.ts b/packages/i18n/src/index.ts index 9fb52c844..fe170a9dc 100644 --- a/packages/i18n/src/index.ts +++ b/packages/i18n/src/index.ts @@ -1,4 +1,2 @@ export * from "./literals"; export * from "./strings"; -export * from "./unwrapper"; -export * from "./wrapper"; diff --git a/packages/i18n/src/strings.ts b/packages/i18n/src/strings.ts index 386979308..adedc75cf 100644 --- a/packages/i18n/src/strings.ts +++ b/packages/i18n/src/strings.ts @@ -1,68 +1,3 @@ -import { merge } from "ts-deepmerge"; -import locales from "../locales.json"; -import en from "../strings/en.json"; -import es from "../strings/es.json"; -import fr from "../strings/fr.json"; -import ja from "../strings/ja.json"; -import pl from "../strings/pl.json"; -import pt from "../strings/pt.json"; -import ru from "../strings/ru.json"; -import uk from "../strings/uk.json"; -import zh from "../strings/zh.json"; +import type en from "../strings/en.json"; -export type BlitzKitStrings = typeof en; - -const stringsRaw: Record = { - en, - es, - fr, - ja, - pl, - pt, - ru, - uk, - zh, -}; - -export const STRINGS: Record = {}; - -for (const locale in stringsRaw) { - if (locale === locales.default) { - STRINGS[locales.default] = stringsRaw[locales.default] as BlitzKitStrings; - continue; - } - - const localeStrings = stringsRaw[locale]; - STRINGS[locale] = merge( - stringsRaw[locales.default], - localeStrings - ) as BlitzKitStrings; -} - -export const SUPPORTED_LOCALE_BLITZ_MAP: Record = { - en: "en", - es: "es", - fr: "fr", - ja: "ja", - pt: "pt", - ru: "ru", - uk: "uk", - zh: "zh-Hans", - pl: "pl", -}; - -export const SUPPORTED_LOCALE_FLAGS: Record = { - en: "πŸ‡ΊπŸ‡Έ", - es: "πŸ‡ͺπŸ‡Έ", - fr: "πŸ‡«πŸ‡·", - ja: "πŸ‡―πŸ‡΅", - pt: "πŸ‡΅πŸ‡Ή", - ru: "πŸ‡·πŸ‡Ί", - uk: "πŸ‡ΊπŸ‡¦", - zh: "πŸ‡¨πŸ‡³", - pl: "πŸ‡΅πŸ‡±", -}; - -export type TranslationTree = { [key: string]: TranslationNode }; - -export type TranslationNode = string | TranslationTree; +export type Strings = typeof en; diff --git a/packages/i18n/src/unwrapper.ts b/packages/i18n/src/unwrapper.ts deleted file mode 100644 index ace1277cd..000000000 --- a/packages/i18n/src/unwrapper.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { I18nString } from "../../core/src"; -import locales from "../locales.json"; - -export function unwrapper(locale = locales.default) { - return function (i18nString: I18nString) { - if (locale in i18nString.locales) { - return i18nString.locales[locale]; - } - - return i18nString.locales[locales.default]; - }; -} diff --git a/packages/i18n/src/wrapper.ts b/packages/i18n/src/wrapper.ts deleted file mode 100644 index 7618cd273..000000000 --- a/packages/i18n/src/wrapper.ts +++ /dev/null @@ -1,15 +0,0 @@ -import locales from "../locales.json"; -import { type BlitzKitStrings, STRINGS } from "./strings"; - -export function wrapper(slicer: (strings: BlitzKitStrings) => string) { - const defaultString = slicer(STRINGS[locales.default] as BlitzKitStrings); - - const object = { [locales.default]: defaultString }; - - for (const { locale } of locales.supported) { - const string = slicer(STRINGS[locale] as BlitzKitStrings); - if (string !== defaultString) object[locale] = string; - } - - return object; -} diff --git a/packages/i18n/strings/en.json b/packages/i18n/strings/en.json index ecf8488a2..dbbbff064 100644 --- a/packages/i18n/strings/en.json +++ b/packages/i18n/strings/en.json @@ -1,6 +1,7 @@ { "common": { - "name": "BlitzKit" + "name": "BlitzKit", + "credit": "by TrΓ¨sAbhi" }, "units": { diff --git a/packages/website-ue/src/components/HomeHero.astro b/packages/website-ue/src/components/HomeHero.astro index ca05f85a9..3004f4f29 100644 --- a/packages/website-ue/src/components/HomeHero.astro +++ b/packages/website-ue/src/components/HomeHero.astro @@ -1,10 +1,17 @@ --- import { MagnifyingGlassIcon } from "@radix-ui/react-icons"; +import { api } from "../core/api/dynamic"; import { BlitzKitIcon } from "../icons/BlitzKit"; import { Code } from "./Code"; import { TextField } from "./TextField"; -const strings = { home: { search: "test" } }; +interface Props { + locale: string; +} + +const { locale } = Astro.props; + +const strings = await api.strings(locale); ---