Skip to content

Reports & Checks

When migrating internationalization in batch, preview, reports, and consistency checks should be part of the standard workflow. This lets you know which files will change before writing, and verify source references match locale files after writing.

Translation Reports

Both tf and tfo support --report <file>:

sh
hias tf src\views\user\index.vue user --dry-run --report .hias\reports\user.json
hias tfo src\views user --report .hias\reports\user-folder.json

Reports are in JSON format, suitable for manual review, CI upload, or script processing:

json
{
  "mode": "dry-run",
  "summary": {
    "filesScanned": 1,
    "filesWithExtractions": 1,
    "replacements": 3,
    "written": 0,
    "skipped": 1,
    "failed": 0
  },
  "files": [
    {
      "file": "src/views/user/index.vue",
      "outputFile": ".hias/lang/user/index.vue",
      "replacements": [
        {
          "text": "User Detail",
          "key": "user.user_detail",
          "context": "attribute",
          "start": 42,
          "end": 53
        }
      ]
    }
  ],
  "failedFiles": []
}

Field descriptions:

FieldDescription
modedry-run or write
summary.filesScannedNumber of files actually scanned
summary.filesWithExtractionsNumber of files with extraction results
summary.replacementsNumber of texts to be replaced or already replaced
summary.writtenNumber of files written
summary.skippedNumber of files skipped
summary.failedNumber of files failed
files[].replacementsExtracted text, key, context, and position for each file
failedFilesFiles that failed syntax validation or processing

Dry Run and Interactive Confirmation

Preview only, don't write files:

sh
hias tfo src\views user --dry-run

Preview then confirm whether to apply:

sh
hias tfo src\views user --interactive

Both can be used with --report:

sh
hias tfo src\views user --dry-run --report .hias\reports\preview.json

Failure Summary

After folder translation, a summary is output:

text
Translation summary
  scanned: 12
  replacements: 35
  written: 10
  skipped: 1
  failed: 1

If a replaced file fails syntax validation, the tool skips it and records the failure reason, avoiding writing results that break syntax.

Consistency Check

hias tcheck checks whether $t(...), this.$t(...), t(...) references in source code match locale JSON files:

sh
hias tcheck src
hias tcheck src --report .hias\reports\tcheck.json

Check content:

TypeDescription
missingKeys referenced in source but missing from all locale files
unusedKeys present in locale files but not referenced in source
inconsistentKeys missing from some locale JSON files
invalid locale filesUnparseable JSON locale files

tcheck is suitable for running after batch migration, and can be added to CI to prevent missing locale files or corrupted JSON from entering the main branch.

Released under the MIT License.