Skip to main content

useL10n

A React Hook to dynamically load translations and locale data for a runner.

Signature

useL10n(
initial: IL10n | undefined,
onL10n: ((l10n: IL10n) => Promise<void>) | undefined,
runner: {
l10n: L10n.Namespace;
update: () => void;
},
purgeCache?: () => void
): [IL10n, (l10n: IL10n) => void, (language?: string) => void]

Parameters

NameTypeOptionalDescription
initialIL10n | undefinedNoSpecifies the initial translations and locale data for the runner.
onL10n((l10n: IL10n) => Promise<void>) | undefinedNoFunction that is invoked when an update of the translations or locale data is requested.
runnerobjectNoReference to the runner.
purgeCache() => voidYesFunction that is invoked when new translations or locale data is loaded.

Return value

Returns a tuple with the current IL10n object, a function to update the IL10n object, and a function to change the language of the runner.