openpencil/tools/i18n/tests/quality.test.ts
Danila Poyarkov 6d96edcc52 fix(i18n): ignore placeholders in script checks
- Strip interpolation tokens before detecting mixed Latin and CJK content\n- Cover placeholder-only and genuinely mixed translations in the i18n tool tests\n- Remove 48 baseline entries that existed only because placeholder names were counted
2026-09-04 18:57:31 +03:00

26 lines
995 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, test } from 'bun:test'
import { hasMixedLatinAndCjk, placeholders, visibleTranslationText } from '../src/quality'
describe('translation quality checks', () => {
test('extracts and removes interpolation placeholders', () => {
expect(placeholders('移除图片 {name},尺寸 {width} × {height}')).toEqual([
'height',
'name',
'width'
])
expect(visibleTranslationText('画像 {name} を削除')).toBe('画像 を削除')
})
test('does not treat placeholder identifiers as translated Latin text', () => {
expect(hasMixedLatinAndCjk('画像 {name} を削除')).toBe(false)
expect(hasMixedLatinAndCjk('查看附件 {name}')).toBe(false)
})
test('still detects visible Latin text mixed with CJK text', () => {
expect(hasMixedLatinAndCjk('画像 OpenPencil を表示')).toBe(true)
expect(hasMixedLatinAndCjk('APIキーを更新')).toBe(true)
expect(hasMixedLatinAndCjk('画像を表示')).toBe(false)
})
})