mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 05:30:46 +08:00
Add uds-auth zh/en i18n, UAC-branded settings, and QR expire/fail overlay.
Wire client locale to the DSH host, return stable API error codes with localized messages, and replace bottom refresh with an in-frame retry for expired or offline QR. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b60c626d41
commit
fd0df9b890
9 changed files with 1183 additions and 202 deletions
53
uds-auth/test/i18n.test.js
Normal file
53
uds-auth/test/i18n.test.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
t,
|
||||
normalizeLocale,
|
||||
apiError,
|
||||
apiOk,
|
||||
roleLabel,
|
||||
roleBadge,
|
||||
MESSAGES,
|
||||
} from '../lib/i18n.js'
|
||||
|
||||
describe('uds-auth i18n', () => {
|
||||
it('normalizes locales', () => {
|
||||
assert.equal(normalizeLocale('en-US'), 'en')
|
||||
assert.equal(normalizeLocale('zh-CN'), 'zh')
|
||||
assert.equal(normalizeLocale(''), 'zh')
|
||||
})
|
||||
|
||||
it('translates UI keys', () => {
|
||||
assert.equal(t('ui.logout', 'zh'), '退出登录')
|
||||
assert.equal(t('ui.logout', 'en'), 'Sign out')
|
||||
})
|
||||
|
||||
it('interpolates vars', () => {
|
||||
assert.equal(t('ui.pager', 'en', { total: 3, page: 1, totalPages: 2 }), '3 users, page 1 / 2')
|
||||
})
|
||||
|
||||
it('returns stable API error codes with localized message', () => {
|
||||
const zh = apiError('not_logged_in', 'zh')
|
||||
const en = apiError('not_logged_in', 'en')
|
||||
assert.equal(zh.error, 'not_logged_in')
|
||||
assert.equal(en.error, 'not_logged_in')
|
||||
assert.equal(zh.message, '未登录')
|
||||
assert.equal(en.message, 'Not signed in')
|
||||
})
|
||||
|
||||
it('returns localized success messages', () => {
|
||||
assert.equal(apiOk('config_saved', 'en').message, 'Config saved')
|
||||
})
|
||||
|
||||
it('role labels are consistent', () => {
|
||||
assert.equal(roleLabel('super_admin', 'zh'), '超级管理员')
|
||||
assert.equal(roleBadge('super_admin', 'zh'), '超管')
|
||||
assert.equal(roleLabel('super_admin', 'en'), 'Super admin')
|
||||
})
|
||||
|
||||
it('zh and en tables share the same keys', () => {
|
||||
const zhKeys = Object.keys(MESSAGES.zh).sort()
|
||||
const enKeys = Object.keys(MESSAGES.en).sort()
|
||||
assert.deepEqual(zhKeys, enKeys)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue