Function translate

  • Example function that translates a given text into the specified languages.

    Type Parameters

    • T extends ("id" | "th" | "tt" | "mn" | "ms" | "so" | "en" | "fr" | "de" | "es" | "it" | "pt" | "ru" | "ja" | "ko" | "zh" | "ar" | "hi" | "bn" | "pa" | "te" | "mr" | "ta" | "ur" | "gu" | "kn" | "ml" | "sd" | "or" | "as" | "bh" | "ks" | "ne" | "si" | "sa" | "my" | "km" | "lo" | "vi" | "tl" | "jv" | "su" | "ceb" | "ny" | "ha" | "yo" | "ig" | "zu" | "xh" | "st" | "tn" | "sn" | "rw" | "rn" | "lg" | "sw" | "mg" | "eo" | "cy" | "eu" | "gl" | "ca" | "ast" | "qu" | "ay" | "gn" | "ug" | "dz" | "bo" | "ii" | "chr" | "iu" | "oj" | "cr" | "yi" | "he" | "fa" | "ps")[]

    Parameters

    • text: string

      The text to translate.

    • Rest ...toLanguages: T

      The languages to translate the text into. Each language should be represented by its code from the languages array (type Language).

    Returns Promise<undefined | MatchingOutput<T>>

    An object where each key is a language code and the corresponding value is the translation of the text into that language.

    Example

    await translate('Hello, world!', 'fr', 'de') // => { fr: 'Bonjour, monde!', de: 'Hallo, Welt!' }
    

Generated using TypeDoc