core library
The comparison engine on its own, without the file system.
Published as package:chki18n/core.dart so it can be imported where
dart:io is not available — a Flutter app on the web, or an editor plugin
running in a browser. Everything here is exported from
package:chki18n/chki18n.dart as well; reach for this entry point when the
build must not pull dart:io in.
Classes
- Chki18nAnalyzer
- A reusable analyzer bound to one set of options.
- Chki18nCheckMeta
- Everything a consumer needs to render a check without hard-coding strings.
- Chki18nDelimiters
-
An opening and closing delimiter pair, as
interpolationPrefixtakes them. - Chki18nEntry
-
One key of one group, as fed to the incremental
checkEntry. - Chki18nInput
-
Input accepted by
analyzeTranslations. - Chki18nIssue
- One finding: what is wrong, where, and how badly it is meant.
- Chki18nKeyUsage
- A key the source asks for, and the file that asks for it.
- Chki18nLevelCount
- How many issues of each severity a set of issues holds.
- Chki18nOptionDefinition
- One option, as both a CLI flag and an API field.
- Chki18nOptions
- Options shared by the CLI and the Dart API.
- Chki18nPluralParts
- The key and the plural form a suffixed key names.
- Chki18nResolvedOptions
- Options after defaults, aliases and text forms have been resolved.
- Chki18nResolvedResult
- Resolved options, and whatever could not be used as given.
- Chki18nResult
- Everything one run found, and what it was run over.
- Chki18nSession
- A set of translations held in memory, checked as often as needed.
- Chki18nSourceFile
- A translation file located by the scanner.
- Chki18nSummary
- Counts a consumer would otherwise have to derive itself.
- Chki18nTextOptions
- Options as text, exactly as a command line gives them.
Enums
- Chki18nCheckCode
- A problem a check can report.
- Chki18nFileFormat
- How translation files are laid out on disk.
- Chki18nGroupBy
- The axis a report groups its issues by.
- Chki18nKeyCase
- Case a project writes the segments of its translation keys in.
- Chki18nLevel
- How badly a reported issue is meant to be taken.
- Chki18nOptionType
- What a command line flag carries after its name.
- Chki18nPluralCategory
- A plural form a language may need, in the order CLDR lists them.
- Chki18nReporter
- How a finished result is rendered.
Constants
-
analyzeCheckCodes
→ const List<
Chki18nCheckCode> - Checks that compare translation data, in report order.
-
checkMeta
→ const Map<
Chki18nCheckCode, Chki18nCheckMeta> - What each check is called, what it means, and how badly it is meant.
-
crossKeyCheckCodes
→ const List<
Chki18nCheckCode> -
Checks that need to see every key of a locale at once, so they cannot be
answered by
checkEntry, which is handed one key at a time. -
defaultExcludeDirs
→ const List<
String> - Directory names never worth scanning for translation files.
-
defaultExcludeFiles
→ const List<
String> -
File names that are never translation files, as
*glob patterns. - defaultGroupBy → const Chki18nGroupBy
- The axis a report groups its issues by, unless one is named.
- defaultInterpolationPrefix → const String
- Opening delimiter of an interpolation placeholder, unless one is named.
- defaultInterpolationSuffix → const String
- Closing delimiter of an interpolation placeholder, unless one is named.
- defaultReporter → const Chki18nReporter
- The reporter a finished result is rendered with, unless one is named.
- defaultReportWidth → const int
- Width a report is laid out at when the terminal does not report its own.
- defaultTargetLocale → const String
- The language every other language is compared against, unless one is named.
-
interpolationDelimiters
→ const List<
Chki18nDelimiters> -
The delimiter pairs detectInterpolationDelimiters knows, in the order it
believes them. A doubled pair comes before its single form, or
{{name}}would be read as{wrapped around{name. - keySeparator → const String
- The separator between the levels of a flattened key.
- maxMeasuredReportWidth → const int
- Widest a report lays itself out to when the width was measured rather than asked for.
-
pluralCategories
→ const List<
Chki18nPluralCategory> - Every plural category, in the order CLDR lists them.
-
reporterByExtension
→ const Map<
String, Chki18nReporter> -
The reporter an
outputfile name implies. -
sourceExtensions
→ const List<
String> - Extensions the unused-key scan will read.
- sourceMaxFileBytes → const int
- Files above this size are skipped by the unused-key scan.
-
supportedExtensions
→ const List<
String> - File extensions the scanner reads.
-
translationFunctions
→ const List<
String> -
Names a translation call goes by, for the
UNDEFINED_KEYscan.
Properties
-
optionDefinitions
→ List<
Chki18nOptionDefinition> -
Every option the CLI and the Dart API share, in the order
--helplists them.final
Functions
-
analyzeTranslations(
Chki18nInput input, {Chki18nOptions? options}) → Chki18nResult - Compares translations held in memory.
-
applyLevelOverrides(
List< Chki18nIssue> issues, Map<Chki18nCheckCode, Chki18nLevel> ? levels) → List<Chki18nIssue> - Re-grades issues whose check the caller asked to report at another severity.
-
buildResult(
List< Chki18nIssue> issues, Chki18nResolvedOptions options, {List<String> locales = const [], List<String> groups = const [], int keyCount = 0, List<Chki18nSourceFile> files = const [], Chki18nFileFormat? fileFormat, int elapsedMs = 0}) → Chki18nResult - Assembles a result around a set of issues.
-
buildUsageText(
String binName) → String -
Usage text for
--help, generated from optionDefinitions. -
charWidth(
String char) → int - Columns one character occupies: none, one, or two.
-
checkKeyShape(
List< Chki18nIssue> issues, String key, String group, Chki18nResolvedOptions options) → void - Checks the shape of a key: the case its segments are written in, and how deeply it is nested.
-
collectFlatKeys(
Object? translations, Set< String> into) → Set<String> -
Every flattened key an object will produce, added to
into. -
collectKeys(
List< TranslationMap> maps, int targetIndex) → List<String> - Keys of every locale, target language first so reports follow its order.
-
createAnalyzer(
{Chki18nOptions? options}) → Chki18nAnalyzer - A reusable analyzer bound to one set of options.
-
createFileExcluder(
Iterable< String> patterns) → bool Function(String) - A test for the files a walk should not read, over the file's own name.
-
createIssue(
Chki18nCheckCode code, {Chki18nLevel? level, String? message, String locale = '', String key = '', String group = '', String? value, String? targetValue, String? interpolation, String? file}) → Chki18nIssue - Builds an issue, taking its severity and its default description from checkMeta so no call site has to repeat them.
-
createPathExcluder(
Iterable< String> entries) → bool Function(List<String> ) - A test for the directories a walk should not enter, over the candidate's path relative to the root, its own name last.
-
createSession(
Chki18nInput input, {Chki18nOptions? options}) → Chki18nSession - Holds a set of translations and checks them repeatedly.
-
detectInterpolationDelimiters(
String text) → Chki18nDelimiters? -
Guesses which delimiters a text writes its interpolation keys with, or
nullwhen nothing in it looks like one. -
displayWidth(
String text) → int - Columns a string occupies, rather than the number of characters in it.
-
extractInterpolationKeys(
Object? value, String prefix, String suffix) → List< String> -
Interpolation keys used by a value, e.g.
['name']forHello {name}. -
extractNumbers(
String value) → List< String> -
Runs of digits a value carries, as text so
03and3stay apart. -
extractTags(
String value) → List< String> - Markup tags a value carries, in the order they appear.
-
findDuplicateKeys(
Object? translations) → List< String> - Flattened keys that more than one definition produces, in the order they are first reached.
-
findInvisibleCharacter(
String value) → String? - The first character in a value that nothing will draw, if there is one.
-
flattenTranslations(
Object? translations) → TranslationMap - Flattens nested translations into the dotted keys the comparison works on.
-
groupIssuesByCode(
List< Chki18nIssue> issues) → Map<Chki18nCheckCode, List< Chki18nIssue> > - Groups issues by check code, in the order the codes were first seen.
-
hasError(
List< Chki18nIssue> issues) → bool -
A run fails only on
errorlevel issues; warnings never block. -
hasTranslatableText(
String value, String prefix, String suffix) → bool - Whether a value holds a word of its own, once the parts that are never translated are taken out.
-
isLocaleCode(
String name) → bool - Whether a name looks like a locale.
-
matchesNamePattern(
String name, String pattern) → bool -
Whether
namematchespattern, where*stands for any run of characters and everything else is literal. Case is ignored, because the file systems these names come from mostly ignore it too. -
nameOfInvisibleCharacter(
String char) → String - How to name an invisible character in a message, since it cannot be shown.
-
optionsFromArgs(
Map< String, Object?> args) → Chki18nOptions - Reads raw CLI arguments into the option shape shared with the Dart API.
-
pathSegments(
String path) → List< String> -
A path as segments, with empty ones and
.dropped. -
pluralBaseOf(
String key) → String? -
The key a plural form belongs to, whichever convention wrote it, or
nullwhen the key is not a plural form at all. -
pluralCategoriesOf(
String locale) → List< Chki18nPluralCategory> ? -
The plural forms a locale's language needs, or
nullwhen the language is not one this table is sure about. -
pluralPartsOf(
String key) → Chki18nPluralParts? -
The key and the plural form a suffixed key names, or
nullwhen the key is an ordinary one.item_oneis theoneform ofitem. -
prepareGroups(
Chki18nInput input, Chki18nResolvedOptions options, List< Chki18nIssue> issues, {bool? flattened}) → TranslationGroups -
Brings the input into the
group -> locale -> flat mapshape the analysis works on. -
reporterOfFileName(
String fileName) → Chki18nReporter - The reporter a file name asks for.
-
resolveOptions(
[Chki18nOptions? options, Chki18nOptions? defaults]) → Chki18nResolvedResult - Fills in defaults and normalises the loose forms an option may take, so that everything downstream reads a single resolved shape.
-
scriptOfLocale(
String locale) → RegExp? -
The script a locale's translations are expected to be written in, or
nullwhen the locale writes in the Latin alphabet, is not listed, or names a script of its own —sr-Latnis Serbian written in Latin, and asking it for Cyrillic would be wrong. -
splitOptionList(
String? value) → List< String> -
Accepts
'A,B'and'A B'alike, and drops what is left over. -
summarizeIssues(
List< Chki18nIssue> issues) → Chki18nSummary - Counts a consumer would otherwise have to derive itself: totals per level, per check code, per locale and per group. Computed in one pass.
-
usesPluralCategory(
String locale, Chki18nPluralCategory category) → bool - Whether a locale's language uses a plural form at all.
Typedefs
-
TranslationGroups
= Map<
String, Map< String, TranslationMap> > -
group name -> locale -> strings. A group is one comparable set of files. -
TranslationMap
= Map<
String, Object?> - Translation strings of one locale.