Module

I18Next

Package
purescript-i18next
Repository
philippedev101/purescript-i18next

#I18n Source

data I18n

Opaque type representing an i18next instance.

#Plugin Source

data Plugin

Opaque type representing an i18next plugin.

#InitOptions Source

type InitOptions = { defaultNS :: String, fallbackLng :: String, interpolation :: { escapeValue :: Boolean }, lng :: String, resources :: Object (Object (Object String)) }

Options for initializing i18next.

resources is keyed by language code, then namespace, then translation key. e.g. { en: { translation: { greeting: "Hello {{name}}" } } }

#defaultOptions Source

defaultOptions :: InitOptions

Sensible defaults for init options.

#use Source

use :: I18n -> Plugin -> Effect I18n

Register a plugin on an i18next instance. Must be called before init.

#init Source

init :: I18n -> InitOptions -> Aff Unit

Initialize i18next with the given options. Returns when ready.

#t Source

t :: I18n -> String -> Effect String

Translate a key. Synchronous after initialization.

#tWithOpts Source

tWithOpts :: I18n -> String -> Foreign -> Effect String

Translate a key with interpolation/pluralization options. Pass any JS-compatible value (record, Foreign.Object, etc.) via unsafeToForeign. e.g. tWithOpts i18n "greeting" (unsafeToForeign { name: "World" }) e.g. tWithOpts i18n "items" (unsafeToForeign { count: 3 })

#changeLanguage Source

changeLanguage :: I18n -> String -> Aff Unit

Switch the active language. Returns when the switch is complete.

#language Source

language :: I18n -> Effect String

Get the current language.

#onLanguageChanged Source

onLanguageChanged :: I18n -> (String -> Effect Unit) -> Effect Unit

Register a callback for language change events.