Skip to content

API

chki18n has four entry points. Which one you want depends on who owns the translations and how often you check them. They share one comparison engine, one option set and one result shape, so moving between them changes only how the data arrives. Every package has all four.

Which entry point

SituationUseReads files
Check a directory once — CI, a script, a pre-commit hookcheckTranslationFilesyes
Check data you already have, onceanalyzeTranslationsno
Read a directory once, then check it repeatedlyloadTranslationsonce
Your own application owns the values and needs only a verdictcreateAnalyzerno

analyzeTranslations and createAnalyzer are also published on their own as chki18n/corepackage:chki18n/core.dartchki18n.core, which reaches no file system at all. See The core entry point.

Every name below is written in its JavaScript spelling. Dart uses the same one; Python is snake_case, so analyzeTranslations is analyze_translations. Getting started states that mapping once.

Who owns the values

This is usually what decides between the four. A session holds its own copy of every string, so session.set and session.checkKey work from memory. If your application is also holding those strings, as a translation editor or a form bound to what a user is typing does, then two copies exist and every edit has to reach both. They drift apart easily.

In that case use createAnalyzer().checkEntry instead: you pass the values in on each call, your application stays the single source of truth, and the check costs about two microseconds.

When chki18n owns the values, as it does in a script, a file watcher or a CI step that checks the same folder twice, the session is much simpler.

Everything else that is exported

Beyond the four entry points:

  • Check metadataCHECK_CODEChki18nCheckCodeCHECK_CODES, CHECK_META, ANALYZE_CHECK_CODES, CROSS_KEY_CHECK_CODES. See Checks.
  • Result helpersgroupIssuesByCode, summarizeIssues, createIssue, buildResult. See The result object.
  • OptionsresolveOptions, argsToOptionsoptionsFromArgsoptions_from_args, buildUsageText, OPTION_DEFINITIONS. See Options.
  • DefaultsDEFAULT_TARGET_LOCALE, DEFAULT_EXCLUDE_DIRS, DEFAULT_INTERPOLATION_PREFIX, DEFAULT_INTERPOLATION_SUFFIX, FILE_FORMATChki18nFileFormatFILE_FORMATS.
  • ReportingformatResult, groupIssues, displayWidth, padTo, truncate. See Options.
  • UtilitiesisLocaleCode, extractInterpolationKeys, scanTranslationDirectory.
  • SessionscreateSession, for translations you pass in rather than a directory.

Every type is exported too.

Chki18nOptions, Chki18nResult, Chki18nIssue, Chki18nSummary, Chki18nEntry, Chki18nSession and the rest.

Chki18nOptions, Chki18nResult, Chki18nIssue, Chki18nSummary, Chki18nEntry, Chki18nSession and the rest. Dart prefixes every public type, so a name never collides with something in the importing library.

Options, Result, Issue, Summary, Entry, Session and the rest. Python does not prefix them, because chki18n.Result already says which library it belongs to.

Released under the MIT License