i18n

t

t(keys, vars)

translate

translate(keys, vars)

Alias of t()

namespacedTranslate

namespacedTranslate(ns, langId = null)

Get a translate function where every key supply is auto-namespaced

formatDate

formatDate(date, format)

Given a date, format it to the current lang date.

formatDateDistance

formatDateDistance(date, baseDate, options= {})

Given two dates, format it in a readable distance like "about 23 hours ago"

formatDateDistanceStrict

formatDateDistanceStrict(date, baseDate, options = {})

Given two dates, format it in a readable distance like "23 hours ago"

formatNumber

formatNumber(number, options)

Format a number.

changeLanguage

changeLanguage(langId)

Changes this current language

language

language()

Gets the current language

resolveLanguages

resolveLanguages()

Gets the list of languages currently used for resolving phrases, from the most specific to fallback

addPhrasePacks

addPhrasePacks(packs)

Adds phrase packs. A phrase pack is an object with a structure: langId.namespaceId.phraseId

const packs = {
    en: {
        main: {
            hello: "hi"
        }
    },
    fr: {
        main: {
            hello: "bonjour"
        }
    },
    // the special $ separator can be used instead of nested namespace ids.
    de$main: {
        hello: "hallo"
    }
};
i18n.addPhrasePacks(packs);

addPhrasePack

addPhrasePack(langId, pack)

Add a single phrase pack.

const pack = {
    main: {
        hello: "hi"
    }
}
i18n.addPhrasePack('en', pack);

addPhrases

addPhrases(langId, ns, phrases)

Add phrases to a specific namespace

hasPhrase

hasPhrase(id)

Check if a phrase exists given the current language setup

hasExactPhrase

hasExactPhrase(langId, ns, phraseId)

Checks if an exact phrase exists.

getExactPhrase

getExactPhrase(langId, ns, phraseId)

Gets an exact phrase.

Last updated