-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.ts
More file actions
42 lines (37 loc) · 1.48 KB
/
index.ts
File metadata and controls
42 lines (37 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* i18n setup for b2c-cli.
*
* This module registers CLI-specific translations with the 'cli' namespace.
* The core i18n infrastructure comes from @salesforce/b2c-tooling.
*
* Usage in commands:
* import { t } from '../i18n/index.js'
* this.log(t('commands.sites.list.fetching', 'Fetching sites from {{hostname}}...', { hostname }))
*/
import {registerTranslations, t as toolingT, type TOptions} from '@salesforce/b2c-tooling';
import {locales} from './locales/index.js';
/** The namespace used by b2c-cli messages */
export const CLI_NAMESPACE = 'cli';
// Register all CLI translations
for (const [lang, translations] of Object.entries(locales)) {
registerTranslations(CLI_NAMESPACE, lang, translations);
}
/**
* Translate a CLI message key with an inline default.
*
* This is a convenience wrapper that uses the 'cli' namespace.
* For b2c-tooling messages, import t directly from @salesforce/b2c-tooling.
*
* @param key - Dot-notation key (e.g., 'commands.sites.list.fetching')
* @param defaultValue - The default English string
* @param options - Optional interpolation values
* @returns The translated string
*
* @example
* t('commands.sites.list.fetching', 'Fetching sites from {{hostname}}...', { hostname })
*/
export function t(key: string, defaultValue: string, options?: TOptions): string {
return toolingT(`${CLI_NAMESPACE}:${key}`, defaultValue, options);
}
// Re-export for convenience
export {setLanguage, getLanguage, getI18nInstance} from '@salesforce/b2c-tooling';