@weresk/locales
v0.1.0
Published
**@weresk/locales** Toolkit for Next.js app localization
Downloads
39
Readme
@weresk/locales Toolkit for Next.js app localization
Exports
Schemas
localeObjects: Generates an array of schema definitios based on list of types and list of languages- Props:
objects: string[]: List of object typeslanguages: {id: string, title: string}[]: List of languages
- Returns:
ReturnType<typeof defineType>[]
- Props:
Constants
ISO_LOCALES: Array of language codes from ISO 639
Types
IsoLocale: Type literal string with language codes from ISO 639LocaleProps<T extends object, Locale extends string | undefined = undefined>: Adds optionallangproperty to a props interfaceLocaleString<Locale extends string = IsoLocale> = Partial<Record<Locale, string>>: Localized string objectLocaleObject<T extends any, Locale extends string = IsoLocale>: Localized any type objectLocalizationConfig<Locale extends string = IsoLocale>: Localization config definitionlanguages: {id: Locale; title: string; abbr: string;}[]: List of languagesdefaultLocale: Locale: ID of a default languagesafeReplace?: boolean: Sets if a default locale should be used if a desired language value is missing
Utils
localize: Localizes locale string object- Arguments:
input: string | Record<string, string> | undefined: Input object or stringlang: string | undefined: Required language idoptions: Options objectsafeReplace: boolean | undefined: If true returns default language valuedefaultLocale: string | undefined: Default language id
- Returns:
string
- Arguments:
selectLocale: Localizes locale any object- Arguments:
input: Record<string, T> | undefined: Input object or stringlang: string | undefined: Required language idoptions: Options objectsafeReplace: boolean | undefined: If true returns default language valuedefaultLocale: string | undefined: Default language id
- Returns:
T
- Arguments:
languageFilterConfig: Generates @sanity/language-filter config from Localization config and list of document types- Arguments:
config: LocalizationConfig: Localization configschemas: string[]: List of document schema types
- Returns:
LanguageFilterConfig
- Arguments:
