@quazardous/qdadm 1.20.0 → 1.21.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/package.json +1 -1
- package/src/i18n/I18n.ts +3 -1
- package/src/i18n/__tests__/I18n.test.ts +31 -0
- package/src/i18n/types.ts +8 -0
package/package.json
CHANGED
package/src/i18n/I18n.ts
CHANGED
|
@@ -59,6 +59,7 @@ export class I18n {
|
|
|
59
59
|
private _appAliases: AliasPattern[]
|
|
60
60
|
private _entityToModule: Map<string, string> = new Map()
|
|
61
61
|
private _signals: I18nDeps['signals']
|
|
62
|
+
private _emitMissing: boolean
|
|
62
63
|
private _defaultLocale: string
|
|
63
64
|
private _fallbackLocale: string
|
|
64
65
|
private _loadedLocales: Set<string> = new Set()
|
|
@@ -76,6 +77,7 @@ export class I18n {
|
|
|
76
77
|
this._strategyName = options.keyStrategy ?? 'global'
|
|
77
78
|
this._appAliases = options.aliases ? [...options.aliases] : []
|
|
78
79
|
this._signals = deps.signals ?? null
|
|
80
|
+
this._emitMissing = options.emitMissing ?? true
|
|
79
81
|
|
|
80
82
|
this._registry = new MessagesRegistry()
|
|
81
83
|
this.inline = new InlineTranslationProvider()
|
|
@@ -99,7 +101,7 @@ export class I18n {
|
|
|
99
101
|
fallbackLocale: this._fallbackLocale,
|
|
100
102
|
globalAliases: this._currentStrategyAliases(),
|
|
101
103
|
onMissing: (key, locale) => {
|
|
102
|
-
this._signals?.emit('i18n:missing', { key, locale })
|
|
104
|
+
if (this._emitMissing) this._signals?.emit('i18n:missing', { key, locale })
|
|
103
105
|
},
|
|
104
106
|
})
|
|
105
107
|
|
|
@@ -105,6 +105,37 @@ describe('I18n — locale change', () => {
|
|
|
105
105
|
})
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
+
describe('I18n — emitMissing flag', () => {
|
|
109
|
+
function makeSignals() {
|
|
110
|
+
const events: Array<{ signal: string; data: unknown }> = []
|
|
111
|
+
return {
|
|
112
|
+
events,
|
|
113
|
+
signals: {
|
|
114
|
+
emit: (signal: string, data: unknown) => {
|
|
115
|
+
events.push({ signal, data })
|
|
116
|
+
},
|
|
117
|
+
on: () => () => {},
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
it('emits i18n:missing on an unresolved key by default', async () => {
|
|
123
|
+
const { events, signals } = makeSignals()
|
|
124
|
+
const i18n = new I18n({ disableDefaultCoreBundle: true }, { signals })
|
|
125
|
+
await i18n.bootstrap()
|
|
126
|
+
i18n.t('totally.unknown.key')
|
|
127
|
+
expect(events.some((e) => e.signal === 'i18n:missing')).toBe(true)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('does not emit i18n:missing when emitMissing is false', async () => {
|
|
131
|
+
const { events, signals } = makeSignals()
|
|
132
|
+
const i18n = new I18n({ disableDefaultCoreBundle: true, emitMissing: false }, { signals })
|
|
133
|
+
await i18n.bootstrap()
|
|
134
|
+
i18n.t('totally.unknown.key')
|
|
135
|
+
expect(events.some((e) => e.signal === 'i18n:missing')).toBe(false)
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
108
139
|
describe('I18n — providers', () => {
|
|
109
140
|
it('loads from a custom TranslationProvider during bootstrap', async () => {
|
|
110
141
|
const provider: TranslationProvider = {
|
package/src/i18n/types.ts
CHANGED
|
@@ -31,4 +31,12 @@ export type {
|
|
|
31
31
|
export interface I18nOptions extends BaseI18nOptions {
|
|
32
32
|
/** Disable shipping qdadm's default core.* bundles (EN + FR). Default: false. */
|
|
33
33
|
disableDefaultCoreBundle?: boolean
|
|
34
|
+
/**
|
|
35
|
+
* Emit the `i18n:missing` debug signal when a key cannot be resolved.
|
|
36
|
+
* Default: `true`. Set to `false` to silence the missing-key stream (e.g. an
|
|
37
|
+
* untranslated app where every key would otherwise fire it) — the debug
|
|
38
|
+
* panel's "Missing" section then stays empty. No functional impact: nothing
|
|
39
|
+
* but the debug collector consumes this signal.
|
|
40
|
+
*/
|
|
41
|
+
emitMissing?: boolean
|
|
34
42
|
}
|