25가지 검사, 하나의 리포트
누락된 키, 비어 있는 값, 번역되지 않은 문자열, 어긋난 보간 키, 보이지 않는 문자, 화면마다 달라진 용어까지 찾아냅니다. 비교 검사의 심각도는 프로젝트에 맞게 조정할 수 있습니다.
검사 항목
번역 파일이 있는 폴더와 기준 언어를 지정하면 됩니다.
npx chki18n ./locales --target endart pub global activate chki18n
chki18n ./locales --target enpip install chki18n
chki18n ./locales --target en Path ./locales
Target en
Locales en, ko
Layout single, 1 group, 10 keys
ko ──────────────────────────────────────────────────────────────────────── 1 error · 1 warning
ERROR NO_KEY (1)
The key exists in the target language but is missing here.
attr.folder en: "Folder"
WARN NOT_TRANSLATED_VALUE (1)
The value is identical to the target language, so the translation may be incomplete.
desc.no-str en: "12345"
Summary ───────────────────────────────────────────────────────────────────────────────────────
Compared 10 keys across 2 locales in 1 group. (3ms)
1 error · 1 warning
Clean: en
FAIL 1 error must be fixed before this passes.오류 수준의 이슈가 있으면 종료 코드 1로 끝나므로 CI 작업이 여기서 실패합니다. 어느 패키지를 설치하든 이 리포트는 열 위치까지 똑같습니다.
같은 검사를 코드에서 실행하면 텍스트 대신 객체를 받습니다.
import { checkTranslationFiles } from 'chki18n';
const result = await checkTranslationFiles('./locales', { target: 'en' });
result.success; // false
result.summary; // { error: 1, warn: 1, info: 0, total: 2, byCode: {…}, byLocale: {…} }
result.issues[0];
// {
// code: 'NO_KEY',
// level: 'error',
// locale: 'ko',
// key: 'attr.folder',
// group: '',
// targetValue: 'Folder',
// file: '/project/locales/ko.json',
// message: 'The key exists in the target language but is missing here.'
// }import 'package:chki18n/chki18n.dart';
final result = await checkTranslationFiles(
path: './locales',
options: const Chki18nOptions(target: 'en'),
);
result.success; // false
result.summary.error; // 1
result.issues.first;
// Chki18nIssue(
// code: Chki18nCheckCode.noKey,
// level: Chki18nLevel.error,
// locale: 'ko',
// key: 'attr.folder',
// group: '',
// targetValue: 'Folder',
// file: '/project/locales/ko.json',
// message: 'The key exists in the target language but is missing here.',
// )from chki18n import Options, check_translation_files
result = check_translation_files("./locales", Options(target="en"))
result.success # False
result.summary.error # 1
result.issues[0]
# Issue(
# code="NO_KEY",
# level="error",
# locale="ko",
# key="attr.folder",
# group="",
# target_value="Folder",
# file="/project/locales/ko.json",
# message="The key exists in the target language but is missing here.",
# )설치는 시작하기 한 페이지면 충분합니다. 각 검사가 무엇을 잡아내는지는 검사 항목에, 모든 옵션은 옵션에 정리되어 있습니다.