Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "src/hooks/useTranslation"

Index

Type aliases

Functions

Type aliases

RealDoc

RealDoc<T>: T

Type parameters

  • T

TranslateFunction

TranslateFunction: (translationKey: string) => string | undefined

Type declaration

    • (translationKey: string): string | undefined
    • Parameters

      • translationKey: string

      Returns string | undefined

Functions

useTranslation

  • Use translation hook provides an easy way to access localized data and provided fallback data

    Parameters

    • currentDoc: RealDoc

      The object structure you wish to localize

    • defaultDoc: RealDoc

      The fallback document of "current doc" if accessing current doc returns undefined or a falsy value

    Returns TranslateFunction

    A function that is used for transitioning values and an instance of the registered localization plugin

    Example:

    const t = useTranslation({heading: "this is a title"}, {heading: "fallback", "body": "this is a body"})
    
    t("heading") // returns "this is a title"
    t("body") // returns  "this is a body"

Generated using TypeDoc