feat(i18n): localize plugin catalog names and shell preset desc
Catalog entry names (15 tab + 4 viewer) and the dsh-desktop shell preset
desc were raw hardcoded zh strings rendered straight into the add-plugin
modals and the title-bar scheme dropdown. Mirror the existing desc
pattern exactly: PluginEntry.name / ShellPreset.desc widen to the
i18n-friendly string-or-() =>-string union, the catalogs carry lazy
t('pluginXxxName') / t('presetDshDesktopDesc') lookups, and the
add-plugin modal (render, search filter, aria-labels) plus the scheme
SelectMenu resolve them like every other copy. The plain-string arm of
the union stays as the raw-name fallback, and t() itself never yields
empty text (missing keys render the key), so a dict gap can never blank
a name.
20 new dictionary keys added to zh/en (locales.ts), ja (locales-ja.ts),
and all 18 third-language dictionaries — tests/locales.spec.ts enforces
key-set equality against zh for every shipped dict (precedent: 9cc642b),
so the 'leave other locales-* untouched' shortcut would fail the hard
parity gate; real translations are provided instead.
Spec follow-ups (behavior change: names/descs now render through t()):
- plugin-list.spec.ts: name non-empty assertion resolves the union.
- add-plugin-modal.spec.tsx: sentinel/office name assertions resolve
from the catalog (en locale in tests) instead of pinning zh literals.
- shell-presets.spec.ts: desc non-empty assertion resolves the union.
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
* Built-in plugin catalog data-integrity tests (both files: the TAB
|
||||
* catalog in plugins-tabs.ts and the FILE-PREVIEWER catalog in
|
||||
* plugins-viewers.ts). Every entry must be installable as data — a unique
|
||||
* id (npm package name), a GitHub URL, a non-empty localized description
|
||||
* (string or () => string), and an install script that mentions the dsh
|
||||
* plugin CLI. The catalogs are the discovery surface of the two "add
|
||||
* plugin" modals; a malformed entry would break the install flow, so the
|
||||
* shape is pinned here.
|
||||
* id (npm package name), a GitHub URL, a non-empty localized name and
|
||||
* description (string or () => string), and an install script that mentions
|
||||
* the dsh plugin CLI. The catalogs are the discovery surface of the two
|
||||
* "add plugin" modals; a malformed entry would break the install flow, so
|
||||
* the shape is pinned here.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { builtinTabPlugins } from '../src/client/plugins-tabs.ts'
|
||||
@@ -42,9 +42,11 @@ describe('builtin plugin catalogs', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('every entry has a name, a GitHub URL, and an install script', () => {
|
||||
it('every entry has a localized name, a GitHub URL, and an install script', () => {
|
||||
for (const entry of list) {
|
||||
expect(entry.name.length).toBeGreaterThan(0)
|
||||
// Names went through the same i18n-friendly union as descriptions
|
||||
// (string or () => string), so resolve before asserting.
|
||||
expect(textOf(entry.name).length).toBeGreaterThan(0)
|
||||
expect(entry.url.startsWith('https://github.com/')).toBe(true)
|
||||
expect(entry.install.length).toBeGreaterThan(0)
|
||||
expect(entry.install).toContain('dsh plugin')
|
||||
|
||||
Reference in New Issue
Block a user