Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
50 lines
2.2 KiB
TypeScript
50 lines
2.2 KiB
TypeScript
import { describe, expect, it, afterEach } from 'vitest';
|
||
import { detectCliLanguage, getCliLanguage, setCliLanguage, t } from '../../src/cli/i18n/index.js';
|
||
import { cliResources } from '../../src/cli/i18n/resources.js';
|
||
|
||
describe('cli i18n', () => {
|
||
afterEach(() => setCliLanguage(null));
|
||
|
||
it('detects Chinese from GitNexus-specific or locale environment variables', () => {
|
||
expect(detectCliLanguage({ GITNEXUS_LANG: 'zh-CN' } as NodeJS.ProcessEnv)).toBe('zh-CN');
|
||
expect(detectCliLanguage({ LC_ALL: 'zh_CN.UTF-8' } as NodeJS.ProcessEnv)).toBe('zh-CN');
|
||
expect(detectCliLanguage({ LANG: 'en_US.UTF-8' } as NodeJS.ProcessEnv)).toBe('en');
|
||
});
|
||
|
||
it('does not map Traditional Chinese locales to Simplified Chinese', () => {
|
||
expect(detectCliLanguage({ LANG: 'zh_TW.UTF-8' } as NodeJS.ProcessEnv)).toBe('en');
|
||
expect(detectCliLanguage({ LANG: 'zh_HK.UTF-8' } as NodeJS.ProcessEnv)).toBe('en');
|
||
expect(detectCliLanguage({ LANG: 'zh-Hant.UTF-8' } as NodeJS.ProcessEnv)).toBe('en');
|
||
});
|
||
|
||
it('supports explicit language override and interpolation', () => {
|
||
setCliLanguage('zh-CN');
|
||
expect(getCliLanguage()).toBe('zh-CN');
|
||
expect(t('list.title', { count: 2 })).toBe('已索引仓库(2)');
|
||
});
|
||
|
||
it('resolves plural suffixes when count is provided', () => {
|
||
setCliLanguage('en');
|
||
expect(t('doctor.nodes', { count: 1 })).toBe('1 node');
|
||
expect(t('doctor.nodes', { count: 2 })).toBe('2 nodes');
|
||
expect(t('doctor.chunks', { count: 1 })).toBe('1 chunk');
|
||
expect(t('doctor.chunks', { count: 2 })).toBe('2 chunks');
|
||
|
||
setCliLanguage('zh-CN');
|
||
expect(t('doctor.nodes', { count: 1 })).toBe('1 个节点');
|
||
expect(t('doctor.nodes', { count: 2 })).toBe('2 个节点');
|
||
});
|
||
|
||
it('keeps base-key interpolation when no plural suffix exists', () => {
|
||
setCliLanguage('en');
|
||
expect(t('list.title', { count: 1 })).toBe('Indexed Repositories (1)');
|
||
});
|
||
|
||
it('keeps resource keys in parity across supported languages', () => {
|
||
const englishKeys = Object.keys(cliResources.en).sort();
|
||
for (const [language, messages] of Object.entries(cliResources)) {
|
||
expect(Object.keys(messages).sort(), language).toEqual(englishKeys);
|
||
}
|
||
});
|
||
});
|