translate-kit

scan

Scan source code for translatable strings.

The scan command parses your JSX/TSX source files and extracts translatable strings using Babel AST analysis.

Usage

translate-kit scan

Flags

FlagDescription
--dry-runPreview found strings without writing files

Requirements

The scan config section must be defined in your config:

export default defineConfig({
  // ...
  scan: {
    include: ["src/**/*.tsx", "app/**/*.tsx"],
    exclude: ["**/*.test.*"],
  },
});

What Gets Extracted

The scanner finds translatable strings in four categories:

JSX Text

<h1>Welcome to our platform</h1>
// → "Welcome to our platform"

JSX Attributes

<input placeholder="Enter your name" />
// → "Enter your name"

Default translatable props: placeholder, title, alt, aria-label, aria-description, aria-placeholder, label.

Expression Containers

<div>{"Hello world"}</div>
// → "Hello world"

Object Properties

const items = [
  { title: "Dashboard", description: "View your stats" },
];
// → "Dashboard", "View your stats"

Only content-related property names are extracted: title, description, label, text, content, heading, subtitle, caption, summary, message, placeholder, alt.

What Gets Filtered Out

The scanner automatically ignores:

  • Strings already wrapped in t() calls
  • Whitespace-only content
  • URLs and email addresses
  • CSS class names and identifiers
  • CONSTANT_CASE values
  • Numbers and currency symbols
  • Content inside <script>, <style>, <code>, <pre>, <svg> tags
  • Non-translatable attributes (className, id, href, src, type, etc.)

Output

Keys mode (default)

The scan command produces two files:

  1. .translate-map.json — a mapping of extracted text to generated keys
  2. Source locale JSON — the message file with generated keys and source text

Inline mode

In inline mode, scan produces only:

  1. .translate-map.json — same text-to-key mapping

No source locale JSON is created — the source text stays in your code. The scanner also detects existing <T> components and inline t(text, id) calls to avoid re-processing them.


Keys are generated using AI for semantic, namespace-style naming (common.save, nav.dashboard, form.enterName).