@zucker-framework/i18n 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,677 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ CompositeMessageSource: () => CompositeMessageSource,
25
+ FileMessageSource: () => FileMessageSource,
26
+ I18n: () => I18n,
27
+ I18nException: () => I18nException,
28
+ I18nSpec: () => I18nSpec,
29
+ LocaleContext: () => LocaleContext,
30
+ LocaleInterceptor: () => LocaleInterceptor,
31
+ LocaleUtils: () => LocaleUtils,
32
+ MESSAGE_SOURCE: () => MESSAGE_SOURCE,
33
+ ZuckerI18nModule: () => ZuckerI18nModule,
34
+ formatDate: () => formatDate,
35
+ formatMessage: () => formatMessage,
36
+ formatNumber: () => formatNumber,
37
+ formatRelativeTime: () => formatRelativeTime,
38
+ getI18nCode: () => getI18nCode,
39
+ hasI18n: () => hasI18n,
40
+ pluralize: () => pluralize
41
+ });
42
+ module.exports = __toCommonJS(index_exports);
43
+
44
+ // src/message-source.ts
45
+ var import_node_fs = require("fs");
46
+ var import_node_path = require("path");
47
+ var import_common = require("@nestjs/common");
48
+ var FileMessageSource = class _FileMessageSource {
49
+ static {
50
+ __name(this, "FileMessageSource");
51
+ }
52
+ basePath;
53
+ logger = new import_common.Logger(_FileMessageSource.name);
54
+ messages = /* @__PURE__ */ new Map();
55
+ defaultLocale;
56
+ constructor(basePath, options) {
57
+ this.basePath = basePath;
58
+ this.defaultLocale = options?.defaultLocale ?? "en";
59
+ }
60
+ getMessage(code, args, defaultMessage, locale) {
61
+ const loc = locale ?? this.defaultLocale;
62
+ const messages = this.loadLocale(loc);
63
+ let message = messages[code];
64
+ if (message === void 0 && loc !== this.defaultLocale) {
65
+ const defaultMessages = this.loadLocale(this.defaultLocale);
66
+ message = defaultMessages[code];
67
+ }
68
+ if (message === void 0) {
69
+ return defaultMessage ?? code;
70
+ }
71
+ return this.interpolate(message, args);
72
+ }
73
+ loadLocale(locale) {
74
+ if (this.messages.has(locale)) {
75
+ return this.messages.get(locale);
76
+ }
77
+ const filePath = (0, import_node_path.join)(this.basePath, `${locale}.json`);
78
+ if (!(0, import_node_fs.existsSync)(filePath)) {
79
+ this.messages.set(locale, {});
80
+ return {};
81
+ }
82
+ try {
83
+ const content = (0, import_node_fs.readFileSync)(filePath, "utf-8");
84
+ const data = JSON.parse(content);
85
+ const flat = this.flatten(data);
86
+ this.messages.set(locale, flat);
87
+ return flat;
88
+ } catch (err) {
89
+ this.logger.warn(`Failed to load i18n messages for locale "${locale}": ${err instanceof Error ? err.message : String(err)}`);
90
+ this.messages.set(locale, {});
91
+ return {};
92
+ }
93
+ }
94
+ flatten(obj, prefix = "") {
95
+ const result = {};
96
+ for (const [key, value] of Object.entries(obj)) {
97
+ const fullKey = prefix ? `${prefix}.${key}` : key;
98
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
99
+ Object.assign(result, this.flatten(value, fullKey));
100
+ } else {
101
+ result[fullKey] = String(value);
102
+ }
103
+ }
104
+ return result;
105
+ }
106
+ interpolate(message, args) {
107
+ if (!args || args.length === 0) return message;
108
+ return message.replace(/\{(\d+)\}/g, (match, index) => {
109
+ const idx = parseInt(index, 10);
110
+ return idx < args.length ? String(args[idx]) : match;
111
+ });
112
+ }
113
+ clearCache() {
114
+ this.messages.clear();
115
+ }
116
+ };
117
+ var CompositeMessageSource = class {
118
+ static {
119
+ __name(this, "CompositeMessageSource");
120
+ }
121
+ sources;
122
+ constructor(sources) {
123
+ this.sources = sources;
124
+ }
125
+ getMessage(code, args, defaultMessage, locale) {
126
+ for (const source of this.sources) {
127
+ const message = source.getMessage(code, args, void 0, locale);
128
+ if (message !== code) {
129
+ return message;
130
+ }
131
+ }
132
+ return defaultMessage ?? code;
133
+ }
134
+ addSource(source) {
135
+ this.sources.push(source);
136
+ }
137
+ /**
138
+ * Add multiple sources at once.
139
+ */
140
+ addSources(sources) {
141
+ this.sources.push(...sources);
142
+ }
143
+ /**
144
+ * Get the number of registered sources.
145
+ */
146
+ getSourceCount() {
147
+ return this.sources.length;
148
+ }
149
+ };
150
+
151
+ // src/locale-context.ts
152
+ var import_node_async_hooks = require("async_hooks");
153
+ var import_common2 = require("@nestjs/common");
154
+ var import_rxjs = require("rxjs");
155
+ function _ts_decorate(decorators, target, key, desc) {
156
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
157
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
158
+ r = Reflect.decorate(decorators, target, key, desc);
159
+ } else {
160
+ for (var i = decorators.length - 1; i >= 0; i--) {
161
+ if (d = decorators[i]) {
162
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
163
+ }
164
+ }
165
+ }
166
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
167
+ }
168
+ __name(_ts_decorate, "_ts_decorate");
169
+ function _ts_metadata(metadataKey, metadataValue) {
170
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
171
+ return Reflect.metadata(metadataKey, metadataValue);
172
+ }
173
+ }
174
+ __name(_ts_metadata, "_ts_metadata");
175
+ var localeStorage = new import_node_async_hooks.AsyncLocalStorage();
176
+ var LocaleContext = class {
177
+ static {
178
+ __name(this, "LocaleContext");
179
+ }
180
+ static defaultLocale = "en";
181
+ static setDefault(locale) {
182
+ this.defaultLocale = locale;
183
+ }
184
+ static getCurrent() {
185
+ return localeStorage.getStore() ?? this.defaultLocale;
186
+ }
187
+ static run(locale, fn) {
188
+ return localeStorage.run(locale, fn);
189
+ }
190
+ static runAsync(locale, fn) {
191
+ return localeStorage.run(locale, fn);
192
+ }
193
+ };
194
+ var LocaleInterceptor = class {
195
+ static {
196
+ __name(this, "LocaleInterceptor");
197
+ }
198
+ supportedLocales;
199
+ defaultLocale;
200
+ constructor(options) {
201
+ this.supportedLocales = new Set(options?.supportedLocales ?? [
202
+ "en",
203
+ "zh"
204
+ ]);
205
+ this.defaultLocale = options?.defaultLocale ?? "en";
206
+ }
207
+ intercept(context, next) {
208
+ const request = context.switchToHttp().getRequest();
209
+ const acceptLanguage = request.headers?.["accept-language"] ?? "";
210
+ const locale = this.parseLocale(acceptLanguage);
211
+ return new import_rxjs.Observable((subscriber) => {
212
+ LocaleContext.runAsync(locale, async () => {
213
+ return new Promise((resolve, reject) => {
214
+ next.handle().subscribe({
215
+ next: /* @__PURE__ */ __name((value) => subscriber.next(value), "next"),
216
+ error: /* @__PURE__ */ __name((err) => {
217
+ subscriber.error(err);
218
+ reject(err);
219
+ }, "error"),
220
+ complete: /* @__PURE__ */ __name(() => {
221
+ subscriber.complete();
222
+ resolve();
223
+ }, "complete")
224
+ });
225
+ });
226
+ }).catch((err) => subscriber.error(err));
227
+ });
228
+ }
229
+ parseLocale(header) {
230
+ if (!header) return this.defaultLocale;
231
+ const parts = header.split(",").map((part) => {
232
+ const [lang, q] = part.trim().split(";q=");
233
+ return {
234
+ lang: lang.trim().split("-")[0].toLowerCase(),
235
+ quality: q ? parseFloat(q) : 1
236
+ };
237
+ });
238
+ parts.sort((a, b) => b.quality - a.quality);
239
+ for (const { lang } of parts) {
240
+ if (this.supportedLocales.has(lang)) {
241
+ return lang;
242
+ }
243
+ }
244
+ return this.defaultLocale;
245
+ }
246
+ };
247
+ LocaleInterceptor = _ts_decorate([
248
+ (0, import_common2.Injectable)(),
249
+ _ts_metadata("design:type", Function),
250
+ _ts_metadata("design:paramtypes", [
251
+ Object
252
+ ])
253
+ ], LocaleInterceptor);
254
+
255
+ // src/i18n-exception.ts
256
+ var import_core = require("@zucker-framework/core");
257
+ var I18nException = class extends import_core.BusinessException {
258
+ static {
259
+ __name(this, "I18nException");
260
+ }
261
+ i18nCode;
262
+ i18nArgs;
263
+ constructor(code, args = [], fallbackMessage) {
264
+ super(fallbackMessage ?? code, code);
265
+ this.i18nCode = code;
266
+ this.i18nArgs = args;
267
+ }
268
+ };
269
+
270
+ // src/i18n-spec.ts
271
+ var I18nSpec = class _I18nSpec {
272
+ static {
273
+ __name(this, "I18nSpec");
274
+ }
275
+ /** i18n message code; if empty, defaultMessage is returned as-is */
276
+ code;
277
+ /** Fallback message when code is not found or not provided */
278
+ defaultMessage;
279
+ /** Nested i18n-aware arguments */
280
+ args;
281
+ constructor(code, defaultMessage, args = []) {
282
+ this.code = code;
283
+ this.defaultMessage = defaultMessage;
284
+ this.args = args;
285
+ }
286
+ /**
287
+ * Create an I18nSpec with optional nested args.
288
+ * Args can be strings (treated as plain defaults) or I18nSpec instances.
289
+ */
290
+ static of(code, defaultMessage, ...args) {
291
+ const specArgs = args.map((arg) => {
292
+ if (typeof arg === "string") {
293
+ return new _I18nSpec(void 0, arg);
294
+ }
295
+ return arg;
296
+ });
297
+ return new _I18nSpec(code, defaultMessage, specArgs);
298
+ }
299
+ /**
300
+ * Add a nested i18n argument.
301
+ */
302
+ withArg(code, defaultMessage, ...args) {
303
+ this.args.push(_I18nSpec.of(code, defaultMessage, ...args));
304
+ return this;
305
+ }
306
+ /**
307
+ * Add an existing I18nSpec as a nested argument.
308
+ */
309
+ withArgSpec(spec) {
310
+ this.args.push(spec);
311
+ return this;
312
+ }
313
+ /**
314
+ * Resolve this spec to a final message using the given MessageSource.
315
+ * Recursively resolves nested args first.
316
+ */
317
+ resolve(messageSource, locale) {
318
+ const currentLocale = locale ?? LocaleContext.getCurrent();
319
+ if (this.args.length === 0) {
320
+ return this.resolveMessage(messageSource, currentLocale);
321
+ }
322
+ const resolvedArgs = this.args.map((arg) => arg.resolve(messageSource, currentLocale));
323
+ return this.resolveMessage(messageSource, currentLocale, resolvedArgs);
324
+ }
325
+ /**
326
+ * Create a shallow copy of this spec.
327
+ */
328
+ copy() {
329
+ return new _I18nSpec(this.code, this.defaultMessage, this.args.map((a) => a.copy()));
330
+ }
331
+ resolveMessage(messageSource, locale, resolvedArgs) {
332
+ if (!this.code) {
333
+ return this.defaultMessage ?? "";
334
+ }
335
+ return messageSource.getMessage(this.code, resolvedArgs, this.defaultMessage, locale);
336
+ }
337
+ };
338
+
339
+ // src/locale-utils.ts
340
+ function formatMessage(template, params) {
341
+ if (Array.isArray(params)) {
342
+ return template.replace(/\{(\d+)\}/g, (match, index) => {
343
+ const idx = parseInt(index, 10);
344
+ return idx < params.length ? String(params[idx]) : match;
345
+ });
346
+ }
347
+ return template.replace(/\{(\w+)\}/g, (match, key) => {
348
+ return key in params ? String(params[key]) : match;
349
+ });
350
+ }
351
+ __name(formatMessage, "formatMessage");
352
+ function pluralize(count, forms, locale) {
353
+ let form;
354
+ if (count === 0 && forms.zero !== void 0) {
355
+ form = forms.zero;
356
+ } else if (count === 1 && forms.one !== void 0) {
357
+ form = forms.one;
358
+ } else {
359
+ form = forms.other;
360
+ }
361
+ const loc = locale ?? LocaleContext.getCurrent();
362
+ const formatted = new Intl.NumberFormat(loc).format(count);
363
+ return form.replace(/\{count\}/g, formatted);
364
+ }
365
+ __name(pluralize, "pluralize");
366
+ function formatDate(date, style = "medium", locale) {
367
+ const loc = locale ?? LocaleContext.getCurrent();
368
+ const d = typeof date === "number" ? new Date(date) : date;
369
+ return new Intl.DateTimeFormat(loc, {
370
+ dateStyle: style
371
+ }).format(d);
372
+ }
373
+ __name(formatDate, "formatDate");
374
+ function formatNumber(value, style = "decimal", options, locale) {
375
+ const loc = locale ?? LocaleContext.getCurrent();
376
+ const opts = {
377
+ style
378
+ };
379
+ if (style === "currency") {
380
+ opts.currency = options?.currency ?? "USD";
381
+ }
382
+ return new Intl.NumberFormat(loc, opts).format(value);
383
+ }
384
+ __name(formatNumber, "formatNumber");
385
+ function formatRelativeTime(date, locale) {
386
+ const loc = locale ?? LocaleContext.getCurrent();
387
+ const d = typeof date === "number" ? new Date(date) : date;
388
+ const diffMs = d.getTime() - Date.now();
389
+ const units = [
390
+ [
391
+ "year",
392
+ 365 * 24 * 60 * 60 * 1e3
393
+ ],
394
+ [
395
+ "month",
396
+ 30 * 24 * 60 * 60 * 1e3
397
+ ],
398
+ [
399
+ "week",
400
+ 7 * 24 * 60 * 60 * 1e3
401
+ ],
402
+ [
403
+ "day",
404
+ 24 * 60 * 60 * 1e3
405
+ ],
406
+ [
407
+ "hour",
408
+ 60 * 60 * 1e3
409
+ ],
410
+ [
411
+ "minute",
412
+ 60 * 1e3
413
+ ],
414
+ [
415
+ "second",
416
+ 1e3
417
+ ]
418
+ ];
419
+ const rtf = new Intl.RelativeTimeFormat(loc, {
420
+ numeric: "auto"
421
+ });
422
+ for (const [unit, ms] of units) {
423
+ if (Math.abs(diffMs) >= ms) {
424
+ const value = Math.round(diffMs / ms);
425
+ return rtf.format(value, unit);
426
+ }
427
+ }
428
+ return rtf.format(0, "second");
429
+ }
430
+ __name(formatRelativeTime, "formatRelativeTime");
431
+ var LocaleUtils = class {
432
+ static {
433
+ __name(this, "LocaleUtils");
434
+ }
435
+ static messageSource = null;
436
+ /**
437
+ * Set the global message source used by resolve helpers.
438
+ */
439
+ static setMessageSource(source) {
440
+ this.messageSource = source;
441
+ }
442
+ /**
443
+ * Get the currently configured global message source.
444
+ */
445
+ static getMessageSource() {
446
+ return this.messageSource;
447
+ }
448
+ /**
449
+ * Resolve a message using the current locale context.
450
+ */
451
+ static resolveMessage(code, ...args) {
452
+ return this.resolveMessageWithDefault(code, code, ...args);
453
+ }
454
+ /**
455
+ * Resolve a message with a default fallback using the current locale context.
456
+ */
457
+ static resolveMessageWithDefault(code, defaultMessage, ...args) {
458
+ if (!this.messageSource) {
459
+ return defaultMessage;
460
+ }
461
+ const locale = LocaleContext.getCurrent();
462
+ return this.messageSource.getMessage(code, args, defaultMessage, locale);
463
+ }
464
+ /**
465
+ * Resolve a message using a specific MessageSource and the current locale.
466
+ */
467
+ static resolveMessageFrom(source, code, defaultMessage, ...args) {
468
+ const locale = LocaleContext.getCurrent();
469
+ return source.getMessage(code, args, defaultMessage, locale);
470
+ }
471
+ /**
472
+ * Resolve a message using a specific locale (ignoring the context locale).
473
+ */
474
+ static resolveMessageForLocale(code, locale, defaultMessage, ...args) {
475
+ if (!this.messageSource) {
476
+ return defaultMessage ?? code;
477
+ }
478
+ return this.messageSource.getMessage(code, args, defaultMessage, locale);
479
+ }
480
+ /**
481
+ * Execute a function within a specific locale context.
482
+ */
483
+ static doWith(locale, fn) {
484
+ return LocaleContext.run(locale, fn);
485
+ }
486
+ /**
487
+ * Execute an async function within a specific locale context.
488
+ */
489
+ static doWithAsync(locale, fn) {
490
+ return LocaleContext.runAsync(locale, fn);
491
+ }
492
+ /**
493
+ * Get the current locale.
494
+ */
495
+ static current() {
496
+ return LocaleContext.getCurrent();
497
+ }
498
+ };
499
+
500
+ // src/decorators.ts
501
+ var i18nRegistry = /* @__PURE__ */ new Map();
502
+ function makeKey(target, propertyKey) {
503
+ const ctorName = target.constructor?.name ?? "Unknown";
504
+ return `${ctorName}.${String(propertyKey)}`;
505
+ }
506
+ __name(makeKey, "makeKey");
507
+ function I18n(code) {
508
+ return (target, propertyKey) => {
509
+ i18nRegistry.set(makeKey(target, propertyKey), code);
510
+ };
511
+ }
512
+ __name(I18n, "I18n");
513
+ function getI18nCode(target, propertyKey) {
514
+ return i18nRegistry.get(makeKey(target, propertyKey));
515
+ }
516
+ __name(getI18nCode, "getI18nCode");
517
+ function hasI18n(target, propertyKey) {
518
+ return i18nRegistry.has(makeKey(target, propertyKey));
519
+ }
520
+ __name(hasI18n, "hasI18n");
521
+
522
+ // src/i18n.module.ts
523
+ var import_common3 = require("@nestjs/common");
524
+ function _ts_decorate2(decorators, target, key, desc) {
525
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
526
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
527
+ r = Reflect.decorate(decorators, target, key, desc);
528
+ } else {
529
+ for (var i = decorators.length - 1; i >= 0; i--) {
530
+ if (d = decorators[i]) {
531
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
532
+ }
533
+ }
534
+ }
535
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
536
+ }
537
+ __name(_ts_decorate2, "_ts_decorate");
538
+ var MESSAGE_SOURCE = "MESSAGE_SOURCE";
539
+ var I18N_MODULE_OPTIONS = /* @__PURE__ */ Symbol("I18N_MODULE_OPTIONS");
540
+ var ZuckerI18nModule = class _ZuckerI18nModule {
541
+ static {
542
+ __name(this, "ZuckerI18nModule");
543
+ }
544
+ static forRoot(options = {}) {
545
+ return {
546
+ module: _ZuckerI18nModule,
547
+ global: true,
548
+ providers: _ZuckerI18nModule.buildProviders(options),
549
+ exports: [
550
+ MESSAGE_SOURCE,
551
+ LocaleInterceptor
552
+ ]
553
+ };
554
+ }
555
+ static forRootAsync(options) {
556
+ const asyncProviders = this.createAsyncProviders(options);
557
+ return {
558
+ module: _ZuckerI18nModule,
559
+ global: true,
560
+ imports: options.imports ?? [],
561
+ providers: [
562
+ ...asyncProviders,
563
+ {
564
+ provide: MESSAGE_SOURCE,
565
+ useFactory: /* @__PURE__ */ __name((opts) => {
566
+ const sources = [];
567
+ if (opts.basePath) {
568
+ sources.push(new FileMessageSource(opts.basePath, {
569
+ defaultLocale: opts.defaultLocale
570
+ }));
571
+ }
572
+ if (opts.messageSources) {
573
+ sources.push(...opts.messageSources);
574
+ }
575
+ return sources.length === 1 ? sources[0] : new CompositeMessageSource(sources);
576
+ }, "useFactory"),
577
+ inject: [
578
+ I18N_MODULE_OPTIONS
579
+ ]
580
+ },
581
+ {
582
+ provide: LocaleInterceptor,
583
+ useFactory: /* @__PURE__ */ __name((opts) => new LocaleInterceptor({
584
+ supportedLocales: opts.supportedLocales,
585
+ defaultLocale: opts.defaultLocale
586
+ }), "useFactory"),
587
+ inject: [
588
+ I18N_MODULE_OPTIONS
589
+ ]
590
+ }
591
+ ],
592
+ exports: [
593
+ MESSAGE_SOURCE,
594
+ LocaleInterceptor
595
+ ]
596
+ };
597
+ }
598
+ static buildProviders(options) {
599
+ const providers = [];
600
+ const sources = [];
601
+ if (options.basePath) {
602
+ sources.push(new FileMessageSource(options.basePath, {
603
+ defaultLocale: options.defaultLocale
604
+ }));
605
+ }
606
+ if (options.messageSources) {
607
+ sources.push(...options.messageSources);
608
+ }
609
+ const messageSource = sources.length === 1 ? sources[0] : new CompositeMessageSource(sources);
610
+ providers.push({
611
+ provide: MESSAGE_SOURCE,
612
+ useValue: messageSource
613
+ });
614
+ providers.push({
615
+ provide: LocaleInterceptor,
616
+ useValue: new LocaleInterceptor({
617
+ supportedLocales: options.supportedLocales,
618
+ defaultLocale: options.defaultLocale
619
+ })
620
+ });
621
+ return providers;
622
+ }
623
+ static createAsyncProviders(options) {
624
+ if (options.useFactory) {
625
+ return [
626
+ {
627
+ provide: I18N_MODULE_OPTIONS,
628
+ useFactory: options.useFactory,
629
+ inject: options.inject ?? []
630
+ }
631
+ ];
632
+ }
633
+ const optionsProvider = {
634
+ provide: I18N_MODULE_OPTIONS,
635
+ useFactory: /* @__PURE__ */ __name(async (factory) => factory.createI18nOptions(), "useFactory"),
636
+ inject: [
637
+ options.useClass ?? options.useExisting
638
+ ]
639
+ };
640
+ if (options.useClass) {
641
+ return [
642
+ {
643
+ provide: options.useClass,
644
+ useClass: options.useClass
645
+ },
646
+ optionsProvider
647
+ ];
648
+ }
649
+ return [
650
+ optionsProvider
651
+ ];
652
+ }
653
+ };
654
+ ZuckerI18nModule = _ts_decorate2([
655
+ (0, import_common3.Global)(),
656
+ (0, import_common3.Module)({})
657
+ ], ZuckerI18nModule);
658
+ // Annotate the CommonJS export names for ESM import in node:
659
+ 0 && (module.exports = {
660
+ CompositeMessageSource,
661
+ FileMessageSource,
662
+ I18n,
663
+ I18nException,
664
+ I18nSpec,
665
+ LocaleContext,
666
+ LocaleInterceptor,
667
+ LocaleUtils,
668
+ MESSAGE_SOURCE,
669
+ ZuckerI18nModule,
670
+ formatDate,
671
+ formatMessage,
672
+ formatNumber,
673
+ formatRelativeTime,
674
+ getI18nCode,
675
+ hasI18n,
676
+ pluralize
677
+ });