mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-10 03:13:20 +08:00
Add Netx Ops i18n and promote settings to a dedicated section.
Localize alarm prompts and UI reason codes for zh/en, and restyle the settings page like uds-auth as its own settings.section. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
909b5d61a7
commit
a4993b2407
18 changed files with 1329 additions and 840 deletions
|
|
@ -35,3 +35,21 @@ test('formatAlarmPrompt keeps human fields without raw sockets', () => {
|
|||
assert.match(text, /PE1 \(10\.0\.0\.1\)/)
|
||||
assert.match(text, /请分析这条关键告警/)
|
||||
})
|
||||
|
||||
test('formatAlarmPrompt switches to English when lang starts with en', () => {
|
||||
const text = formatAlarmPrompt({
|
||||
action: 'deleted',
|
||||
rule_label: 'Power Down',
|
||||
object_name: 'PORT-1',
|
||||
perceived_severity: 'critical',
|
||||
native_probable_cause: 'LOS',
|
||||
time_created: '2026-01-01T00:00:00Z',
|
||||
notification_id: 'n1',
|
||||
alarm_key: 'k1',
|
||||
ne: { host_name: 'PE1', ip_address: '10.0.0.1' },
|
||||
}, 'en-US')
|
||||
assert.match(text, /Alarm Cleared/)
|
||||
assert.match(text, /Device: PE1 \(10\.0\.0\.1\)/)
|
||||
assert.match(text, /Please analyze this key alarm/)
|
||||
assert.doesNotMatch(text, /告警/)
|
||||
})
|
||||
|
|
|
|||
39
test/i18n.test.mjs
Normal file
39
test/i18n.test.mjs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
|
||||
import {
|
||||
alarmActionLabel,
|
||||
normalizeNetxLocale,
|
||||
tHost,
|
||||
} from '../src/netx/i18n.ts'
|
||||
import { getSessionsExportStatus } from '../src/netx/session-export.ts'
|
||||
|
||||
test('normalizeNetxLocale defaults to zh and accepts en tags', () => {
|
||||
assert.equal(normalizeNetxLocale(undefined), 'zh')
|
||||
assert.equal(normalizeNetxLocale(''), 'zh')
|
||||
assert.equal(normalizeNetxLocale('zh-CN'), 'zh')
|
||||
assert.equal(normalizeNetxLocale('en'), 'en')
|
||||
assert.equal(normalizeNetxLocale('en-US'), 'en')
|
||||
assert.equal(normalizeNetxLocale('english'), 'en')
|
||||
})
|
||||
|
||||
test('tHost localizes alarm session titles', () => {
|
||||
assert.equal(tHost('alarm.sessionTitle', 'zh'), 'Netx 关键告警')
|
||||
assert.equal(tHost('alarm.sessionTitle', 'en'), 'Netx key alarm')
|
||||
assert.equal(alarmActionLabel('inserted', 'en'), 'Alarm Raised')
|
||||
})
|
||||
|
||||
test('getSessionsExportStatus returns reasonCode for UI i18n', async () => {
|
||||
const missing = await getSessionsExportStatus({ get: () => undefined })
|
||||
assert.equal(missing.available, false)
|
||||
assert.equal(missing.reasonCode, 'no_persistence')
|
||||
|
||||
const noRaw = await getSessionsExportStatus({
|
||||
get: () => ({
|
||||
supportsRawArtifacts: false,
|
||||
list: async () => [],
|
||||
readRaw: async () => undefined,
|
||||
}),
|
||||
})
|
||||
assert.equal(noRaw.reasonCode, 'no_raw_artifacts')
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue