Skip to main content

Quik Framework :: Internationalization

Provides internationalization support. The setup routine creates a QI18n instance with configured languages and registers CLI commands for translation utilities.

Installation

npm install @quik/i18n

Configuration

Environment overrides:

  • I18N_DEBUG
  • I18N_DEFAULT_LANG (default: en)
  • I18N_SUPPORTED_LANGS (comma-separated)
  • I18N_COOKIE (default: quik:lang)

Usage

Translate a key:

import { getI18n } from '@quik/core';

const message = getI18n().translate('app.welcome', { name: 'Quik' });

Load resource folders manually:

import { QI18n } from '@quik/i18n';

const i18n = new QI18n({ supportedLanguages: [ 'en' ] });
i18n.loadFolder('./locales');
await i18n.setup();

loadFolder() ignores files for unsupported languages and can recurse subfolders when the second argument is true.

File Naming & Fallbacks

Locale files must be named using the language code (for example en.json, fr.json). When loadFolder() is called with recursion enabled, nested folders are scanned as well.

When a key is missing in the requested language, QI18n falls back to the configured fallback language (defaults to en). If the key is still missing, the key itself is returned as the translation string.

API Highlights

  • QI18n class for loading and translating resources.
  • getI18n() from @quik/core returns the active instance.
  • setupHttpEngine(engine, type) wires i18next middleware.

Testing & Coverage

See the root instructions for details on running pnpm run test:coverage and accessing coverage artifacts.

API Reference

Generated API documentation is available in the i18n API section.