Skip to main content

@boost/translate

build status npm version

Package and application level translations made easy. Wraps the powerful i18next library to abstract complexity away and define common server-side settings.

import { createTranslator } from '@boost/translate';

const msg = await createTranslator(['common', 'errors'], '../path/to/resources');

msg('common:welcome', { name: 'Boost' }); // Hello Boost!

Features

  • Isolated translator instances.
  • Namespace aware resource bundles.
  • Automatic locale detection, from command line options, or from the operating system.
  • Supports multiple file types: JavaScript, JSON, YAML.
  • Message interpolation, pluralization, nesting, and more.
  • Plus all other features found in i18next!

Installation

yarn add @boost/translate

Documentation

Index

Type Aliases

Direction

Direction: ltr | rtl

Format

Format: cjs | js | json | mjs | yaml

InterpolationParams

InterpolationParams: Record<string, unknown>

Locale

Locale: string

TranslateErrorCode

TranslateErrorCode: keyof typeof errors

Variables

constTranslateError

TranslateError: new (code: LOCALE_REQUIRED | NAMESPACE_REQUIRED | RESOURCE_PATH_INVALID | RESOURCES_REQUIRED, params?: unknown[]) => Error & ScopedError<LOCALE_REQUIRED | NAMESPACE_REQUIRED | RESOURCE_PATH_INVALID | RESOURCES_REQUIRED> = ...