1.0.3 • Published 5 months ago

@_apparatus_/intl-localize v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@_apparatus_/intl-localize

bundle size

A lightweight localization library with a good set of features for basic needs.

Installation

npm install @_apparatus_/intl-localize

Features

  • Dynamic Loading: Load translations for different locales and modules on demand.
  • Plugable: Customizable formatting using external libraries such as MessageFormat (IC), Fluent, etc.
  • Nesting: Nest translations using a simple <:nested.key/> syntax.
  • Tagging: Wrap translations with html-like tags for rich text formatting.
  • Typed translations: Provides a typed proxy to easier access to translations, ensuring type safety.

Examples

Basic Usage

import { createLocalizer } from '@_apparatus_/intl-localize'

const localizer = createLocalizer<TTranslations, TTag>({
    load: (locale, module) => {
        /* load your translations dynamically */
    },
    parse: (locale: string, module: string, key: string[], raw: string) => {
        /* custom parser function for formatting library integrations */
    },
    notify: (locale: string, module: string, promise: Promise<Resource>) => {
        /* get notified when modules are being loaded and translations called for rendering library integrations */
    },
    tag: (children: TTag | string, tag: string) => {
        /* transform html-like tags inside translations for custom rendering */
    },
})
1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago