Skip to content

@i18n-micro/utils

102 exports across 24 entry points. Generated from the API snapshot that pnpm run api:surface checks against the TypeScript sources.

@i18n-micro/utils/accept-language

ts
import { /* … */ } from '@i18n-micro/utils/accept-language'
ExportKindSignature
applyAutoDetectLanguagefunction(locale: string, hasExplicitPreference: boolean, autoDetectLanguage: boolean | undefined, acceptLanguageHeader: string | undefined, validLocales: string[]) => string
detectLocaleFromAcceptLanguagefunction(header: string | undefined, validLocales: string[]) => string | null
parseAcceptLanguagefunction(header: string | undefined) => string[]

@i18n-micro/utils/active-locales

ts
import { /* … */ } from '@i18n-micro/utils/active-locales'
ExportKindSignature
getEnabledLocaleCodesfunction(locales?: Locale[] | null) => string[]
getEnabledLocalesfunction(locales?: Locale[] | null) => Locale[]
isEnabledLocalefunction(locales: Locale[] | null | undefined, code: string) => boolean

@i18n-micro/utils/app-path

ts
import { /* … */ } from '@i18n-micro/utils/app-path'
ExportKindSignature
withoutAppBaseURLfunction(pathname: string, baseURL?: string | null) => string

@i18n-micro/utils/auto-detect-path

ts
import { /* … */ } from '@i18n-micro/utils/auto-detect-path'
ExportKindSignature
shouldAttemptLocaleRedirectfunction(path: string, options?: { autoDetectPath?: string; hasLocalePrefix?: boolean; }) => boolean

@i18n-micro/utils/build

ts
import { /* … */ } from '@i18n-micro/utils/build'
ExportKindSignature
buildTranslationSourceLayersfunction(rootDirs: string[], translationDirName: string, outputDir: string) => Promise<void>
PreMergeLocaleInfointerface2 members
preMergeLocalesfunction(rootDirs: string[], translationDirName: string, outputDir: string, locales: PreMergeLocaleInfo[], globalFallbackLocale?: string, disablePageLocales?: boolean) => Promise<void>
PreMergeLocaleInfo — 2 members
MemberType
codestring
fallbackLocale?string | undefined
## `@i18n-micro/utils/cache-control`
ts
import { /* … */ } from '@i18n-micro/utils/cache-control'
ExportKindSignature
CacheControlclass<T>
CacheControlOptionsinterface2 members
CacheControl — 13 members
MemberType
cacheprivate Map<string, T>
clear() => void
configure(options: CacheControlOptions) => void
delete(key: string) => boolean
expiryprivate Map<string, number>
get(key: string) => T | undefined
has(key: string) => boolean
keys() => IterableIterator<string>
maxSizeprivate number
new<T>(options?: CacheControlOptions | undefined): CacheControl<T>
set(key: string, value: T) => void
sizenumber
ttlMsprivate number
CacheControlOptions — 2 members
MemberType
maxSize?number | undefined
ttl?number | undefined
## `@i18n-micro/utils/cookie`
ts
import { /* … */ } from '@i18n-micro/utils/cookie'
ExportKindSignature
DEFAULT_COOKIE_MAX_AGEconstnumber
DEFAULT_COOKIE_NAMEconst"user-locale"
DEFAULT_HASH_COOKIE_NAMEconst"hash-locale"
getHashCookieNamefunction(config: ModuleOptionsExtend) => string | null
getLocaleCookieNamefunction(config: ModuleOptionsExtend) => string | null
getLocaleCookieOptionsfunction() => { expires: Date; maxAge: number; path: string; watch: boolean; sameSite: "lax"; }

@i18n-micro/utils/deep-merge

ts
import { /* … */ } from '@i18n-micro/utils/deep-merge'
ExportKindSignature
deepMergeTranslationsfunction(target: Record<string, unknown>, source: Record<string, unknown>) => Record<string, unknown>
deepMergeTranslationsRecursivefunction(target: Record<string, unknown>, source: Record<string, unknown>) => Record<string, unknown>

@i18n-micro/utils/merge-i18n-head

ts
import { /* … */ } from '@i18n-micro/utils/merge-i18n-head'
ExportKindSignature
I18nHeadObjectinterface3 members
mergeI18nHeadfunction(base: I18nHeadObject, override: I18nHeadInput | null | undefined, options?: MergeI18nHeadOptions) => I18nHeadObject
MergeI18nHeadOptionsinterface3 members
I18nHeadObject — 3 members
MemberType
htmlAttrsRecord<string, string | undefined>
linkI18nHeadLink[]
metaI18nHeadMeta[]
MergeI18nHeadOptions — 3 members
MemberType
currentLocale?string | undefined
identifierAttribute?string | undefined
locales?Locale[] | undefined
## `@i18n-micro/utils/merge-source`
ts
import { /* … */ } from '@i18n-micro/utils/merge-source'
ExportKindSignature
buildFallbackLocaleChainfunction(locale: string, locales: SourceLocaleInfo[], globalFallbackLocale?: string) => string[]
buildSourcePagePathfunction(pageName: string, localeCode: string) => string
buildSourceRootPathfunction(localeCode: string) => string
mergeSourceTranslationsfunction(input: MergeSourceTranslationsInput) => Promise<Record<string, unknown>>
MergeSourceTranslationsInputinterface6 members
mergeTranslationsFromFallbackChainfunction(chain: string[], readLocaleFile: (relativePath: string) => Record<string, unknown>, relativePathForLocale: (localeCode: string) => string) => Record<string, unknown>
mergeTranslationsFromFallbackChainAsyncfunction(chain: string[], readLocaleFile: (relativePath: string) => Record<string, unknown> | Promise<Record<string, unknown>>, relativePathForLocale: (localeCode: string) => string) => Promise<Record<string, unknown>>
normalizeConfiguredLocalesfunction(locales: Array<string | Locale> | undefined) => SourceLocaleInfo[]
resolveSourcePageNamefunction(pageName: string, disablePageLocales?: boolean) => string
SourceLocaleInfointerface2 members
toPremergedStorageKeyfunction(pageName: string, locale: string) => string
toSourceStorageKeyfunction(relativePath: string) => string
MergeSourceTranslationsInput — 6 members
MemberType
disablePageLocales?boolean | undefined
globalFallbackLocale?string | undefined
localestring
localesSourceLocaleInfo[]
pageNamestring
readLocaleFile(relativePath: string) => Record<string, unknown> | Promise<Record<string, unknown>>
SourceLocaleInfo — 2 members, identical to `PreMergeLocaleInfo` above. ## `@i18n-micro/utils/normalize`
ts
import { /* … */ } from '@i18n-micro/utils/normalize'
ExportKindSignature
toTranslationRecordfunction(data: unknown) => Record<string, unknown>
toTranslationsfunction(data: unknown) => Translations

@i18n-micro/utils/parse-path

ts
import { /* … */ } from '@i18n-micro/utils/parse-path'
ExportKindSignature
classifyTranslationRelativePathfunction(relativePath: string, disablePageLocales?: boolean) => ParsedTranslationRelativePath
mergeRouteTranslationsWithRootfunction<T extends Record<string, unknown>>(rootTranslations: T | undefined, routeTranslations: T) => T
pagePathSegmentsToRouteNamefunction(segments: string[]) => string | null
ParsedTranslationRelativePathtype{ type: 'page'; pageName: string; locale: string } | { type: 'root'; locale: string } | { type: 'ignore' }
parseTranslationRelativePathfunction(relativePath: string) => ParsedTranslationRelativePath
storeLoadedTranslationFilefunction<T extends Record<string, unknown>>(buckets: TranslationFileBuckets<T>, relativePath: string, translations: T, disablePageLocales?: boolean) => void
TranslationFileBucketsinterface<T = Record<string, unknown>>
TranslationFileBuckets — 2 members
MemberType
rootRecord<string, T>
routesRecord<string, Record<string, T>>
## `@i18n-micro/utils/payload-config`
ts
import { /* … */ } from '@i18n-micro/utils/payload-config'
ExportKindSignature
DEFAULT_TRANSLATION_PAYLOAD_WARN_FILE_COUNTconst500
DEFAULT_TRANSLATION_PAYLOAD_WARN_SIZE_BYTESconstnumber
formatBytesfunction(bytes: number) => string
getTranslationPayloadMisconfigurationWarningsfunction(input: TranslationPayloadMisconfigurationInput) => string[]
getTranslationPayloadSizeWarningfunction(stats: TranslationPayloadStats, thresholds?: TranslationPayloadSizeThresholds) => string | null
hasLocalTranslationPayloadOutputfunction(translationPayloads: ResolvedTranslationPayloadOptions) => boolean
ResolvedTranslationPayloadOptionsinterface8 members
resolveTranslationPayloadModefunction(options: ModuleOptions) => TranslationPayloadMode
resolveTranslationPayloadOptionsfunction(options: ModuleOptions) => ResolvedTranslationPayloadOptions
resolveTranslationPayloadPublicDirfunction(outputPublicDir: string | undefined, options: ModuleOptions, apiBaseUrl?: string) => string
resolveTranslationPayloadPublicRelfunction(options: ModuleOptions, apiBaseUrl?: string) => string
resolveTranslationPayloadWarningThresholdsfunction(options?: TranslationPayloadOptions) => Required<TranslationPayloadSizeThresholds>
shouldCopyTranslationPayloadsToPublicfunction(translationPayloads: ResolvedTranslationPayloadOptions, isNode: boolean) => boolean
shouldRegisterNitroServerAssetsfunction(translationPayloads: ResolvedTranslationPayloadOptions, isNode: boolean) => boolean
TranslationPayloadMisconfigurationInputinterface3 members
TranslationPayloadModetype'premerged' | 'source'
TranslationPayloadSizeThresholdsinterface2 members
TranslationPayloadStatsinterface2 members
ResolvedTranslationPayloadOptions — 8 members
MemberType
modeTranslationPayloadMode
prerenderRoutesboolean
publicAssetsboolean
publicDir?string | undefined
serverAssetsboolean
serverHandlerboolean
warnFileCount?number | undefined
warnSizeBytes?number | undefined
TranslationPayloadMisconfigurationInput — 3 members
MemberType
apiBaseClientHost?string | undefined
apiBaseServerHost?string | undefined
translationPayloadsResolvedTranslationPayloadOptions
TranslationPayloadSizeThresholds — 2 members
MemberType
warnFileCount?number | undefined
warnSizeBytes?number | undefined
TranslationPayloadStats — 2 members
MemberType
fileCountnumber
totalBytesnumber
## `@i18n-micro/utils/payload-fetch`
ts
import { /* … */ } from '@i18n-micro/utils/payload-fetch'
ExportKindSignature
fetchTranslationPayloadFromHostfunction(config: TranslationPayloadHostConfig, locale: string, page: string, fetcher: TranslationPayloadFetcher) => Promise<Translations>
TranslationPayloadFetchertype<T>(path: string, options: { baseURL: string; params?: Record<string, string | number> }) => Promise<T>
TranslationPayloadHostConfiginterface3 members
TranslationPayloadHostConfig — 3 members
MemberType
apiBaseServerHost?string | undefined
apiBaseUrl?string | undefined
dateBuild?string | number | undefined
## `@i18n-micro/utils/payload-stats`
ts
import { /* … */ } from '@i18n-micro/utils/payload-stats'
ExportKindSignature
compressTranslationPayloadsfunction(dir: string, compression: PublicAssetCompression) => number
hashTranslationSourcesfunction(rootDirs: string[], translationDirName: string) => string | null
PublicAssetCompressiontypeboolean | { gzip?: boolean; brotli?: boolean } | undefined
scanTranslationPayloadDirectoryfunction(dir: string) => TranslationPayloadStats

@i18n-micro/utils/payload-url

ts
import { /* … */ } from '@i18n-micro/utils/payload-url'
ExportKindSignature
buildTranslationPayloadCacheControlfunction(durationSeconds: number | undefined, hasCacheBuster?: boolean) => string | null
buildTranslationPayloadFetchRequestfunction(input: TranslationPayloadFetchRequestInput) => { path: string; baseURL: string; params?: Record<string, string | number>; }
buildTranslationPayloadPathfunction(apiBaseUrl: string, page: string, locale: string) => string
resolveTranslationPayloadBaseURLfunction(options: { isServer: boolean; baseURL: string; apiBaseClientHost?: string; apiBaseServerHost?: string; }) => string
resolveTranslationPayloadPagefunction(routeName: string | undefined, routesLocaleLinks?: Record<string, string>) => string
TranslationPayloadFetchRequestInputinterface9 members
TranslationPayloadFetchRequestInput — 9 members
MemberType
apiBaseClientHost?string | undefined
apiBaseServerHost?string | undefined
apiBaseUrlstring
baseURLstring
dateBuild?string | number | undefined
isServerboolean
localestring
routeName?string | undefined
routesLocaleLinks?Record<string, string> | undefined
## `@i18n-micro/utils/resolve-hreflang`
ts
import { /* … */ } from '@i18n-micro/utils/resolve-hreflang'
ExportKindSignature
HreflangAlternateinterface2 members
HreflangLocaleInputtypePick<Locale, 'code' | 'iso'>
resolveHreflangAlternatesfunction(locales: HreflangLocaleInput[], options?: ResolveHreflangAlternatesOptions) => HreflangAlternate[]
ResolveHreflangAlternatesOptionsinterface1 members
HreflangAlternate — 2 members
MemberType
hreflangstring
localeCodestring
ResolveHreflangAlternatesOptions — 1 members
MemberType
hreflangBaseLanguage?boolean | undefined
## `@i18n-micro/utils/resolve-locale`
ts
import { /* … */ } from '@i18n-micro/utils/resolve-locale'
ExportKindSignature
resolvePreferredLocalefunction(input: ResolvePreferredLocaleInput) => string
ResolvePreferredLocaleInputinterface7 members
resolveServerLocalefunction(input: ResolveServerLocaleInput) => string
ResolveServerLocaleInputinterface8 members
ResolvePreferredLocaleInput — 7 members
MemberType
acceptLanguageHeader?string | null | undefined
autoDetectLanguage?boolean | undefined
cookieLocale?string | null | undefined
defaultLocalestring
ignoreStateLocale?boolean | undefined
stateLocale?string | null | undefined
validLocalesstring[]
ResolveServerLocaleInput — 8 members
MemberType
acceptLanguageHeader?string | null | undefined
autoDetectLanguage?boolean | undefined
cookieLocale?string | null | undefined
defaultLocalestring
hasLocaleInUrlboolean
queryLocale?string | null | undefined
urlLocale?string | null | undefined
validLocalesstring[]
## `@i18n-micro/utils/resolve-og-locale`
ts
import { /* … */ } from '@i18n-micro/utils/resolve-og-locale'
ExportKindSignature
resolveOgLocalefunction(locale: OgLocaleInput) => string | null
warnUnresolvedOgLocalefunction(locale: OgLocaleInput, options?: WarnUnresolvedOgLocaleOptions) => void
WarnUnresolvedOgLocaleOptionsinterface2 members
WarnUnresolvedOgLocaleOptions — 2 members
MemberType
missingWarn?boolean | undefined
tag?"og:locale" | "og:locale:alternate" | undefined
## `@i18n-micro/utils/route`
ts
import { /* … */ } from '@i18n-micro/utils/route'
ExportKindSignature
findAllowedLocalesForRoutefunction(route: I18nRouteContext, routeLocales: Record<string, string[]> | undefined, localizedRouteNamePrefix?: string, localeCodes?: string[]) => string[] | null
I18nRouteContextinterface3 members
isMetaDisabledForRoutefunction(route: I18nRouteContext, routeDisableMeta: Record<string, boolean | string[]> | undefined, currentLocale?: string, localizedRouteNamePrefix?: string) => boolean
I18nRouteContext — 3 members
MemberType
matched?{ path: string; }[] | undefined
name?string | symbol | null | undefined
pathstring
## `@i18n-micro/utils/route-pattern`
ts
import { /* … */ } from '@i18n-micro/utils/route-pattern'
ExportKindSignature
extractBaseRoutePatternfunction(matchedPath: string) => string
routeNameToPathfunction(normalizedRouteName: string | undefined) => string | undefined
stripLeadingSlashfunction(path: string) => string
stripLocalizedRouteNamePrefixfunction(routeName: string | undefined | null, localizedRouteNamePrefix?: string) => string | undefined

@i18n-micro/utils/runtime-config

ts
import { /* … */ } from '@i18n-micro/utils/runtime-config'
ExportKindSignature
resolveI18nConfigWithRuntimeOverridesfunction(baseConfig: ModuleOptionsExtend, runtimePublic?: Record<string, unknown>, warn?: (message: string) => void) => ModuleOptionsExtend
RuntimeI18nOverridesinterface4 members
RuntimeI18nOverrides — 4 members
MemberType
defaultLocale?string | undefined
disabledLocales?string[] | undefined
fallbackLocale?string | undefined
strategy?string | undefined
## `@i18n-micro/utils/source-loader`
ts
import { /* … */ } from '@i18n-micro/utils/source-loader'
ExportKindSignature
loadSourceTranslationsFromStoragefunction(storage: TranslationStorageReader, input: Omit<MergeSourceTranslationsInput, "readLocaleFile">) => Promise<Translations>
TranslationStorageReaderinterface1 members
TranslationStorageReader — 1 members
MemberType
getItem(key: string) => Promise<unknown>
## `@i18n-micro/utils/split-locale-routes`
ts
import { /* … */ } from '@i18n-micro/utils/split-locale-routes'
ExportKindSignature
SplitLocaleRouteEntryinterface4 members
SplitLocaleRoutePageinterface3 members
splitLocaleRoutesfunction(entries: readonly SplitLocaleRouteEntry[]) => SplitLocaleRoutesResult
SplitLocaleRoutesResultinterface2 members
SplitLocaleRouteEntry — 4 members
MemberType
filestring
namestring
pathstring
paths?false | Record<string, string> | undefined
SplitLocaleRoutePage — 3 members
MemberType
filestring
namestring
pathstring
SplitLocaleRoutesResult — 2 members
MemberType
globalLocaleRoutesRecord<string, boolean | Record<string, string>>
pagesSplitLocaleRoutePage[]

Back to all packages · Integration guides

Released under the MIT License.