/** * Internationalization (i18n) support for B2C CLI tools. * * This module provides translation utilities using i18next, with support for * multiple languages and environment-based language detection. * * ## Key Features * * - Default strings are stored inline at point of use (no separate en.ts needed) * - TypeScript locale files for type safety and bundling * - Namespace separation: 'b2c' for tooling, 'cli' for CLI-specific messages * * ## Language Detection * * Language is detected in this order: * 1. Explicit {@link setLanguage} call (from --lang flag) * 2. `LANGUAGE` environment variable (GNU gettext standard) * 3. `LANG` system environment variable (Unix standard) * 4. Default: 'en' * * ## Supported Locale Formats * * - `de` - simple language code * - `de_DE` - language with country * - `de-DE` - language with country (hyphen) * - `de_DE.UTF-8` - with encoding * - `de:en:fr` - colon-separated preference list (LANGUAGE only) * * ## Usage * * ```typescript * import { t } from '@salesforce/b2c-tooling-sdk'; * * // Simple translation with inline default * const message = t('error.serverRequired', 'Server is required.'); * * // With interpolation * const fileError = t('error.fileNotFound', 'File {{path}} not found.', { * path: '/foo/bar' * }); * ``` * * ## Adding Translations * * ```typescript * import { registerTranslations } from '@salesforce/b2c-tooling-sdk'; * * // Register translations for a new namespace * registerTranslations('my-package', 'de', { * greeting: 'Hallo Welt' * }); * ``` * * @module i18n */ import { type TOptions } from 'i18next'; /** * Options for i18next translation string interpolation. * * Passed as the third parameter to {@link t | t()} to provide dynamic values * for placeholder variables in translation strings (i18next double-brace syntax). * * @example * t('error.fileNotFound', 'File {{path}} not found.', { path: '/foo/bar' }) * * @see https://www.i18next.com/interpolation.html */ export type { TOptions } from 'i18next'; /** The namespace used by b2c-tooling messages */ export declare const B2C_NAMESPACE = "b2c"; /** * Translate a message key with an inline default. * * The default string is used directly during development and serves as * the English translation. Future localization adds translations via * locale files without changing call sites. * * @param key - Dot-notation key (e.g., 'error.serverRequired') * @param defaultValue - The default English string * @param options - Optional interpolation values * @returns The translated string * * @example * // Simple usage * t('error.serverRequired', 'Server is required.') * * @example * // With interpolation * t('error.fileNotFound', 'File {{path}} not found.', { path: filePath }) * * @example * // With multiple interpolations * t('info.uploadProgress', 'Uploading {{file}} ({{percent}}%)', { file: name, percent: 50 }) */ export declare function t(key: string, defaultValue: string, options?: TOptions): string; /** * Set the language for translations. * Call this early in CLI initialization if --lang flag is provided. * * @param lang - Language code (e.g., 'en', 'de') * @returns void * * @example * // In BaseCommand.init() * if (this.flags.lang) { * setLanguage(this.flags.lang) * } */ export declare function setLanguage(lang: string): void; /** * Get the currently active language. * * @returns The currently active language code (e.g., 'en', 'de') */ export declare function getLanguage(): string; /** * Get the i18next instance for advanced usage. * * Use this to: * - Add translations from other packages (e.g., b2c-cli adding 'cli' namespace) * - Add additional languages at runtime * * @example * // Add a new namespace from b2c-cli * getI18nInstance().addResourceBundle('de', 'cli', { * command: { * sites: { description: 'Sites-Befehle' } * } * }) * * @example * // Add a new language * getI18nInstance().addResourceBundle('fr', 'b2c', { * error: { * serverRequired: 'Le serveur est requis.' * } * }) * * @returns The i18next instance for advanced usage */ export declare function getI18nInstance(): import("i18next", { with: { "resolution-mode": "require" } }).i18n; /** * Register translations for a namespace. * * This is the primary way for packages to add their translations. * Each package should use its own namespace. * * @param namespace - The namespace (e.g., 'cli' for b2c-cli) * @param lang - Language code (e.g., 'de') * @param resources - Translation object * * @example * // In b2c-cli initialization * registerTranslations('cli', 'de', { * command: { * sites: { description: 'Sites-Befehle' } * } * }) */ export declare function registerTranslations(namespace: string, lang: string, resources: Record): void;