shallok 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -24
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/package.json +10 -11
- package/skills/astro-localization-and-translation-i18n/SKILL.md +105 -32
- package/skills/astro-localization-and-translation-i18n/references/astro-i18n.md +15 -0
- package/skills/astro-localization-and-translation-i18n/references/extraction.md +6 -1
- package/skills/astro-localization-and-translation-i18n/references/frameworks.md +59 -0
- package/skills/astro-localization-and-translation-i18n/references/translation.md +30 -4
- package/skills/astro-localization-and-translation-i18n/references/versioning.md +22 -6
- package/skills/expo-localization-and-translation-i18n/SKILL.md +116 -35
- package/skills/expo-localization-and-translation-i18n/references/expo-localization.md +56 -11
- package/skills/expo-localization-and-translation-i18n/references/extraction.md +6 -1
- package/skills/expo-localization-and-translation-i18n/references/frameworks.md +59 -0
- package/skills/expo-localization-and-translation-i18n/references/translation.md +30 -4
- package/skills/expo-localization-and-translation-i18n/references/versioning.md +22 -6
- package/skills/localization-and-translation-i18n/SKILL.md +116 -28
- package/skills/localization-and-translation-i18n/references/extraction.md +6 -1
- package/skills/localization-and-translation-i18n/references/frameworks.md +26 -7
- package/skills/localization-and-translation-i18n/references/translation.md +30 -4
- package/skills/localization-and-translation-i18n/references/versioning.md +22 -6
- package/skills/nextjs-localization-and-translation-i18n/SKILL.md +107 -35
- package/skills/nextjs-localization-and-translation-i18n/references/extraction.md +6 -1
- package/skills/nextjs-localization-and-translation-i18n/references/frameworks.md +59 -0
- package/skills/nextjs-localization-and-translation-i18n/references/next-intl.md +14 -2
- package/skills/nextjs-localization-and-translation-i18n/references/translation.md +30 -4
- package/skills/nextjs-localization-and-translation-i18n/references/versioning.md +22 -6
- package/skills/react-localization-and-translation-i18n/SKILL.md +116 -35
- package/skills/react-localization-and-translation-i18n/references/extraction.md +6 -1
- package/skills/react-localization-and-translation-i18n/references/frameworks.md +59 -0
- package/skills/react-localization-and-translation-i18n/references/react-i18next.md +54 -8
- package/skills/react-localization-and-translation-i18n/references/translation.md +30 -4
- package/skills/react-localization-and-translation-i18n/references/versioning.md +22 -6
- package/skills/localize-app/SKILL.md +0 -80
- package/skills/localize-app/references/extraction.md +0 -29
- package/skills/localize-app/references/frameworks.md +0 -25
- package/skills/localize-app/references/translation.md +0 -45
- package/skills/localize-app/references/versioning.md +0 -57
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
# Translation Engine & Agent-Native Translation Reference
|
|
2
2
|
|
|
3
3
|
## Agent-Native Translation (Primary Workflow)
|
|
4
|
-
When using Shallok via an AI coding agent (e.g., in Claude, Cursor, Copilot
|
|
4
|
+
When using Shallok via an AI coding agent (e.g., in Antigravity, Claude, Cursor, Copilot):
|
|
5
5
|
- **No external API keys or LLM provider subscriptions are needed.**
|
|
6
6
|
- The AI agent itself generates accurate, natural translations for each target locale.
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- **Always verify context first**: Before translating any key, check that all keys in `localization_base/<source_locale>.json` have proper semantic context. If any key lacks context or has generic AST context, generate rich context before translating.
|
|
8
|
+
- **Always translate from `localization_base/<source_locale>.json` and its context**: Never translate raw isolated string fragments. Combine the canonical source `content` and its semantic `context` to generate culturally authentic, grammatically correct translations.
|
|
9
|
+
- Inspect `messages/<locale>.json` or run `shallok status --json` to identify entries with `status: "missing"` or `status: "stale"`.
|
|
10
|
+
- Write the translated strings into `messages/<locale>.json` (or use `shallok entry set <locale> <key> "<translated_text>"`).
|
|
11
|
+
|
|
12
|
+
## Core Rules for Translations
|
|
13
|
+
|
|
14
|
+
### 1. Pre-Flight Verification & Persistence
|
|
15
|
+
- Before making changes to a new or existing repo, verify `shallok` is installed and check that `localization.json` and `localization_base/` exist. If not, initialize with `shallok init`.
|
|
16
|
+
- **NEVER delete `localization.json` or `localization_base/`**. They hold the single source of truth, content hashes, version counters, and context.
|
|
17
|
+
|
|
18
|
+
### 2. Normalized Dot-Paths for Keys
|
|
19
|
+
- All keys must use normalized dot notation (e.g., `"checkout.pay_now"`, `"auth.login.title"`).
|
|
20
|
+
- Never use nested object structures. If an existing codebase uses nested objects for keys, ask the user to convert/flatten them to normalized dot-path keys.
|
|
21
|
+
|
|
22
|
+
### 3. Standardized `messages/` Folder
|
|
23
|
+
- All translations must reside in `messages/` (`messages/<locale>.json` and `messages/runtime/<locale>.json`).
|
|
24
|
+
- If an existing project uses another directory (such as `locales/`, `src/locales/`, `translations/`), ask the user to switch to `messages/` and migrate existing files.
|
|
25
|
+
|
|
26
|
+
### 4. Context Verification Before Translation
|
|
27
|
+
- Check all keys in `localization_base/<source_locale>.json` have meaningful semantic context.
|
|
28
|
+
- If any key lacks context, generate clear context describing the screen, element, and user action before initiating translation.
|
|
29
|
+
|
|
30
|
+
### 5. Always Translate from Source Locale Catalog + Context
|
|
31
|
+
- Read both `content` and `context` from `localization_base/<source_locale>.json`.
|
|
32
|
+
- Preserve all interpolation placeholders (`{name}`, `{count}`, `{amount}`) exactly as formatted.
|
|
33
|
+
|
|
34
|
+
---
|
|
9
35
|
|
|
10
36
|
### Translation Schema
|
|
11
37
|
Each entry in `messages/<locale>.json` maintains:
|
|
@@ -35,7 +61,7 @@ The AI agent must strictly preserve all interpolation placeholders in target tra
|
|
|
35
61
|
- Kannada: `"ಮರಳಿ ಸ್ವಾಗತ, {userName}! ನಿಮ್ಮ ಕಾರ್ಟ್ನಲ್ಲಿ {itemCount} ಐಟಂಗಳು ಇವೆ."`
|
|
36
62
|
- Hindi: `"वापसी पर स्वागत है, {userName}! आपके कार्ट में {itemCount} आइटम हैं।"`
|
|
37
63
|
|
|
38
|
-
If a translation drops a placeholder or introduces an invalid placeholder, `
|
|
64
|
+
If a translation drops a placeholder or introduces an invalid placeholder, `shallok validate` will fail with an error.
|
|
39
65
|
|
|
40
66
|
---
|
|
41
67
|
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
# Per-Key Versioning & Context Reference
|
|
2
2
|
|
|
3
|
+
## Strict Catalog Persistence: NEVER Delete `localization.json` or `localization_base/`
|
|
4
|
+
> [!CAUTION]
|
|
5
|
+
> `localization.json` and `localization_base/` are the permanent foundation of the localization system:
|
|
6
|
+
> - `localization.json` stores project settings, locales, paths, and key strategies.
|
|
7
|
+
> - `localization_base/` stores canonical source strings, per-key version counters (`key_version`), cryptographic SHA-256 hashes (`content_hash`), occurrence positions, and enriched semantic `context`.
|
|
8
|
+
> - **Under NO circumstances should you EVER delete `localization.json` or `localization_base/`**. Deleting them resets version counters, destroys human- and AI-enriched context, breaks incremental translation, and corrupts catalog synchronization.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
3
12
|
## Canonical Source Catalog (`localization_base/`)
|
|
4
13
|
The canonical catalog is the single source of truth for all active and obsolete keys, including their cryptographic content hashes and version counters.
|
|
5
14
|
|
|
15
|
+
### Key Format: Normalized Dot-Separated Paths Only
|
|
16
|
+
- All keys must use normalized dot-separated string paths (e.g. `"checkout.pay_now"`, `"auth.login.title"`).
|
|
17
|
+
- **Never use nested object-based keys**.
|
|
18
|
+
- If an existing project uses object-based keys, ask the user to convert and flatten them to normalized dot-paths before modifying catalogs.
|
|
19
|
+
|
|
6
20
|
### Structure of a Canonical Entry
|
|
7
21
|
```json
|
|
8
22
|
{
|
|
@@ -26,12 +40,14 @@ The canonical catalog is the single source of truth for all active and obsolete
|
|
|
26
40
|
}
|
|
27
41
|
```
|
|
28
42
|
|
|
29
|
-
## Context Enrichment
|
|
30
|
-
1. When strings are extracted via `
|
|
31
|
-
2.
|
|
32
|
-
|
|
43
|
+
## Context Enrichment & Verification Before Translation
|
|
44
|
+
1. When strings are extracted via `shallok extract`, the CLI provides baseline AST context (e.g. `JSX text in <button> (in App <button>)`).
|
|
45
|
+
2. **Mandatory Check Before Translation**: Before generating any translations, check that all active keys in `localization_base/<source_locale>.json` have proper, high-quality semantic context.
|
|
46
|
+
3. If any key lacks context or has only generic AST descriptions, analyze the source code, component hierarchy, and user flow, and enrich the `context` with semantic clarity:
|
|
47
|
+
- CLI method: `shallok context set <key> "<semantic_description>"`
|
|
33
48
|
- Direct edit: Update `"context"` in `localization_base/<source_locale>.json`.
|
|
34
|
-
|
|
49
|
+
4. **Always Translate from Source Locale + Context**: Translations must be derived directly from `localization_base/<source_locale>.json` using BOTH `content` and `context`.
|
|
50
|
+
5. **Preservation Guarantee**:
|
|
35
51
|
Shallok's reconciliation algorithm (`reconcileCanonicalCatalog`) checks if a key already has an enriched context. Unless the source code introduces an explicit inline comment (`{/* context: ... */}`), the AI agent's enriched context is **strictly preserved** across all future extractions and will not be overwritten by generic AST node descriptions.
|
|
36
52
|
|
|
37
53
|
## Reconciliation & Versioning Rules
|
|
@@ -54,4 +70,4 @@ In `messages/<locale>.json`, each entry records:
|
|
|
54
70
|
}
|
|
55
71
|
}
|
|
56
72
|
```
|
|
57
|
-
A translation is **stale** when `entry.source_version < canonicalEntry.key_version`. Stale entries retain their existing translated value for reference until the AI agent updates them
|
|
73
|
+
A translation is **stale** when `entry.source_version < canonicalEntry.key_version`. Stale entries retain their existing translated value for reference until the AI agent updates them from `localization_base/<source_locale>.json` and its enriched `context`.
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: localize-app
|
|
3
|
-
description: Instructions and workflows for AI coding agents to inspect, initialize, extract, version, enrich context, translate, and maintain localization in web applications without requiring external translation API keys.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Localize App Skill (Agent-Native Workflow)
|
|
7
|
-
|
|
8
|
-
Use this skill when asked to add, configure, update, or audit localization in a project (e.g., *"Add localization to this application"*, *"Add Kannada and Hindi"*, *"Translate new strings"*, *"Update stale translations"*).
|
|
9
|
-
|
|
10
|
-
## Two Ways Developers Use Shallok
|
|
11
|
-
|
|
12
|
-
1. **Via CLI (`npx shallok init`)**: The developer runs `npx shallok init` in their project. Shallok initializes the catalogs, installs `shallok` into `devDependencies`, and adds this skill directly into `.agents/skills/` and `skills/`.
|
|
13
|
-
2. **Direct Skill Installation**: The developer installs or links this skill into their AI coding agent and directly asks: *"Add localization to this application"* or *"Translate into Kannada and Hindi"*.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Agent Step 0: Verify & Install Shallok CLI
|
|
18
|
-
|
|
19
|
-
**Before executing any localization commands, you (the AI Agent) MUST verify that `shallok` is available:**
|
|
20
|
-
|
|
21
|
-
1. Check `package.json` for `"shallok"` in `devDependencies` or run:
|
|
22
|
-
```bash
|
|
23
|
-
npx shallok --version
|
|
24
|
-
```
|
|
25
|
-
2. **If `shallok` is NOT installed, install it immediately** using the project's package manager:
|
|
26
|
-
- If `pnpm-lock.yaml` exists: `pnpm add -D shallok`
|
|
27
|
-
- If `yarn.lock` exists: `yarn add -D shallok`
|
|
28
|
-
- If `bun.lockb` / `bun.lock` exists: `bun add -d shallok`
|
|
29
|
-
- Otherwise: `npm install -D shallok`
|
|
30
|
-
*(Alternatively, run commands directly via `npx shallok <command>`)*
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Core Architecture & Agent Role
|
|
35
|
-
|
|
36
|
-
Shallok pairs a deterministic AST CLI (`shallok`) with **the AI Agent as the translator and context enricher**:
|
|
37
|
-
|
|
38
|
-
1. **The CLI (`shallok`)** handles deterministic tasks:
|
|
39
|
-
- AST extraction and safe code transformations (`shallok extract`).
|
|
40
|
-
- Per-key versioning and SHA-256 hash reconciliation (`localization_base/`).
|
|
41
|
-
- Runtime message compilation (`shallok build`).
|
|
42
|
-
- Placeholder and catalog integrity checks (`shallok validate`).
|
|
43
|
-
|
|
44
|
-
2. **The AI Agent (You)** handles semantic intelligence:
|
|
45
|
-
- **No external API keys or LLM provider keys needed!** You, as the AI agent, generate the translations directly.
|
|
46
|
-
- **Context Enrichment**: You analyze the UI components, user flows, and screen layouts to provide rich, meaningful semantic `context` in `localization_base/` for each key.
|
|
47
|
-
- **Culturally Appropriate Translations**: You translate the strings into configured target locales while strictly preserving interpolation tokens (e.g., `{count}`, `{name}`).
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## 6-Phase Agent Workflow
|
|
52
|
-
|
|
53
|
-
### Phase A: Analyze
|
|
54
|
-
Execute read-only repository inspection before making changes:
|
|
55
|
-
```bash
|
|
56
|
-
shallok analyze --json
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Phase B: Plan and Review
|
|
60
|
-
Present a concise plan to the developer (framework, router, locales, scaffolding).
|
|
61
|
-
|
|
62
|
-
### Phase C: Initialize
|
|
63
|
-
```bash
|
|
64
|
-
shallok init --source en --locales kn,hi --framework <name> --yes
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Phase D: Extract & Enrich Context
|
|
68
|
-
1. Preview proposed extraction: `shallok extract --dry-run --json`
|
|
69
|
-
2. Extract strings: `shallok extract`
|
|
70
|
-
3. Enrich Context: `shallok context set <key> "<semantic_description>"`
|
|
71
|
-
|
|
72
|
-
### Phase E: Translate (AI-Driven)
|
|
73
|
-
1. Check status: `shallok status --json`
|
|
74
|
-
2. Generate Natural Translations preserving `{tokens}`.
|
|
75
|
-
3. Update catalog directly or via: `shallok entry set <locale> <key> "<translated_text>"`
|
|
76
|
-
|
|
77
|
-
### Phase F: Apply, Build & Validate
|
|
78
|
-
1. Transform source components: `shallok extract --apply`
|
|
79
|
-
2. Compile runtime message bundles: `shallok build`
|
|
80
|
-
3. Validate catalog integrity: `shallok validate`
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# AST Extraction Reference
|
|
2
|
-
|
|
3
|
-
## Extraction Strategy
|
|
4
|
-
Shallok uses Babel AST parsing (`@babel/parser` and `@babel/traverse`) with full JSX and TypeScript support to safely inspect and transform source files without regular expressions.
|
|
5
|
-
|
|
6
|
-
## What is Extracted
|
|
7
|
-
1. **JSX Text Nodes**:
|
|
8
|
-
- `<h1>Welcome</h1>` → `{t('home.welcome')}`
|
|
9
|
-
- `<button>Pay now</button>` → `<button>{t('checkout.pay_now')}</button>`
|
|
10
|
-
2. **User-Facing Attributes**:
|
|
11
|
-
- `placeholder="Enter your email"`
|
|
12
|
-
- `aria-label="Submit login form"`
|
|
13
|
-
- `title="Cart summary"`
|
|
14
|
-
- `alt="Product thumbnail"`
|
|
15
|
-
- `label="Password"`
|
|
16
|
-
3. **Conditional UI Expressions**:
|
|
17
|
-
- `{isMember ? 'VIP Member' : 'Guest User'}`
|
|
18
|
-
4. **Template Literals with Variables**:
|
|
19
|
-
- `Hello, ${name}!` → `Hello, {name}!` with variable preservation.
|
|
20
|
-
|
|
21
|
-
## What is Explicitly Ignored
|
|
22
|
-
- Technical attributes: `className`, `id`, `name`, `key`, `ref`, `type`, `href`, `src`, `data-testid`, `role`.
|
|
23
|
-
- Console and logger calls: `console.log(...)`, `console.error(...)`, `logger.debug(...)`.
|
|
24
|
-
- URLs, file paths, hex colors, CSS units.
|
|
25
|
-
- Non-user-facing strings, code constants, and symbols.
|
|
26
|
-
- Already localized calls: `t(...)`, `i18n.t(...)`.
|
|
27
|
-
|
|
28
|
-
## Dry-Run Mode
|
|
29
|
-
Always use `localize extract --dry-run` to preview keys and occurrences before committing changes to source files.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Framework Adapters Reference
|
|
2
|
-
|
|
3
|
-
## Supported Frameworks
|
|
4
|
-
|
|
5
|
-
### 1. React (`react-i18next`)
|
|
6
|
-
- **Initialization**: Generates `src/i18n.ts` configuring `i18next` with `initReactI18next`.
|
|
7
|
-
- **Runtime Messages**: Generates clean key-value message files in `messages/<locale>.json`.
|
|
8
|
-
- **AST Transformation**:
|
|
9
|
-
- Adds `import { useTranslation } from 'react-i18next';`
|
|
10
|
-
- Injects `const { t } = useTranslation();` in components
|
|
11
|
-
- Replaces text with `{t('key')}`
|
|
12
|
-
|
|
13
|
-
### 2. Next.js (`next-intl`)
|
|
14
|
-
- **App Router Support**:
|
|
15
|
-
- Generates `src/i18n/routing.ts` defining `locales` and `defaultLocale`.
|
|
16
|
-
- Generates `src/i18n/request.ts` using `getRequestConfig`.
|
|
17
|
-
- **Runtime Messages**: Generates runtime message files in `messages/<locale>.json`.
|
|
18
|
-
- **AST Transformation**:
|
|
19
|
-
- Adds `import { useTranslations } from 'next-intl';`
|
|
20
|
-
- Injects `const t = useTranslations();` in components
|
|
21
|
-
- Replaces text with `{t('key')}`
|
|
22
|
-
|
|
23
|
-
### 3. Vue (`vue-i18n`)
|
|
24
|
-
- **Initialization**: Generates `src/i18n.ts` using `createI18n`.
|
|
25
|
-
- **Runtime Messages**: Generates nested runtime message files in `messages/<locale>.json`.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Translation Engine & Agent-Native Translation Reference
|
|
2
|
-
|
|
3
|
-
## Agent-Native Translation (Primary Workflow)
|
|
4
|
-
When using Shallok via an AI coding agent (e.g., in Claude, Cursor, Copilot, Antigravity):
|
|
5
|
-
- **No external API keys or LLM provider subscriptions are needed.**
|
|
6
|
-
- The AI agent itself generates accurate, natural translations for each target locale.
|
|
7
|
-
- The AI agent inspects `messages/<locale>.json` or runs `localize status --json` to identify entries with `status: "missing"` or `status: "stale"`.
|
|
8
|
-
- The AI agent writes the translated strings into `messages/<locale>.json` (or uses `localize entry set <locale> <key> "<translated_text>"`).
|
|
9
|
-
|
|
10
|
-
### Translation Schema
|
|
11
|
-
Each entry in `messages/<locale>.json` maintains:
|
|
12
|
-
```json
|
|
13
|
-
{
|
|
14
|
-
"checkout.pay_now": {
|
|
15
|
-
"value": "ಈಗ ಪಾವತಿಸಿ",
|
|
16
|
-
"source_version": 1,
|
|
17
|
-
"translated_at": "2026-10-19T14:00:00.000Z",
|
|
18
|
-
"status": "translated"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Supported Statuses
|
|
24
|
-
- `missing`: Key exists in canonical catalog but has no translation.
|
|
25
|
-
- `stale`: Key source version was incremented; old translation preserved for reference.
|
|
26
|
-
- `translated`: Translated and matching the current canonical `source_version`.
|
|
27
|
-
- `review_required`: Flagged for human review.
|
|
28
|
-
- `approved`: Formally approved translation.
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## Placeholder Preservation Rules
|
|
33
|
-
The AI agent must strictly preserve all interpolation placeholders in target translations:
|
|
34
|
-
- Source: `"Welcome back, {userName}! You have {itemCount} items in your cart."`
|
|
35
|
-
- Kannada: `"ಮರಳಿ ಸ್ವಾಗತ, {userName}! ನಿಮ್ಮ ಕಾರ್ಟ್ನಲ್ಲಿ {itemCount} ಐಟಂಗಳು ಇವೆ."`
|
|
36
|
-
- Hindi: `"वापसी पर स्वागत है, {userName}! आपके कार्ट में {itemCount} आइटम हैं।"`
|
|
37
|
-
|
|
38
|
-
If a translation drops a placeholder or introduces an invalid placeholder, `localize validate` will fail with an error.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## CLI-Based Translation (Optional / Fallback)
|
|
43
|
-
For automated pipelines or scripts running outside an interactive AI agent:
|
|
44
|
-
1. **Mock Provider (`mock`)**: Default provider with built-in dictionary for local development and CI testing.
|
|
45
|
-
2. **LLM Provider (`llm`)**: Calls OpenAI, Gemini, or Anthropic HTTP APIs when `TRANSLATION_API_KEY` is provided.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Per-Key Versioning & Context Reference
|
|
2
|
-
|
|
3
|
-
## Canonical Source Catalog (`localization_base/`)
|
|
4
|
-
The canonical catalog is the single source of truth for all active and obsolete keys, including their cryptographic content hashes and version counters.
|
|
5
|
-
|
|
6
|
-
### Structure of a Canonical Entry
|
|
7
|
-
```json
|
|
8
|
-
{
|
|
9
|
-
"checkout.pay_now": {
|
|
10
|
-
"key": "checkout.pay_now",
|
|
11
|
-
"content": "Pay now",
|
|
12
|
-
"context": "Primary action button on checkout screen to trigger payment modal",
|
|
13
|
-
"relative_file_path": "src/components/checkout.tsx",
|
|
14
|
-
"occurrences": [
|
|
15
|
-
{
|
|
16
|
-
"relative_file_path": "src/components/checkout.tsx",
|
|
17
|
-
"line": 42,
|
|
18
|
-
"column": 12
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"last_updated_at": "2026-10-19T10:00:00.000Z",
|
|
22
|
-
"key_version": 1,
|
|
23
|
-
"content_hash": "sha256:...",
|
|
24
|
-
"status": "active"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Context Enrichment by AI Agents
|
|
30
|
-
1. When strings are extracted via `localize extract`, the CLI provides baseline AST context (e.g. `JSX text in <button> (in App <button>)`).
|
|
31
|
-
2. The AI Agent analyzes the source code, component hierarchy, and user flow, and enriches the `context` with semantic clarity:
|
|
32
|
-
- CLI method: `localize context set <key> "<semantic_description>"`
|
|
33
|
-
- Direct edit: Update `"context"` in `localization_base/<source_locale>.json`.
|
|
34
|
-
3. **Preservation Guarantee**:
|
|
35
|
-
Shallok's reconciliation algorithm (`reconcileCanonicalCatalog`) checks if a key already has an enriched context. Unless the source code introduces an explicit inline comment (`{/* context: ... */}`), the AI agent's enriched context is **strictly preserved** across all future extractions and will not be overwritten by generic AST node descriptions.
|
|
36
|
-
|
|
37
|
-
## Reconciliation & Versioning Rules
|
|
38
|
-
1. **New Key**: Initialized at `key_version = 1`, `status = "active"`.
|
|
39
|
-
2. **Unchanged Content & Context**: `key_version` and `last_updated_at` remain unchanged.
|
|
40
|
-
3. **Modified Source Content**: `key_version` increments by 1; `last_updated_at` is updated.
|
|
41
|
-
4. **File Move / Occurrence Change**: Path and occurrence lines are updated; `key_version` does NOT increment.
|
|
42
|
-
5. **Key Removed from Source**: Marked `status = "obsolete"`; preserved in catalog for historical retention.
|
|
43
|
-
6. **Key Reintroduced**: Reactivated as `"active"`.
|
|
44
|
-
|
|
45
|
-
## Stale Detection in Locale Catalogs
|
|
46
|
-
In `messages/<locale>.json`, each entry records:
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"checkout.pay_now": {
|
|
50
|
-
"value": "ಈಗ ಪಾವತಿಸಿ",
|
|
51
|
-
"source_version": 1,
|
|
52
|
-
"translated_at": "2026-10-19T10:05:00.000Z",
|
|
53
|
-
"status": "translated"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
A translation is **stale** when `entry.source_version < canonicalEntry.key_version`. Stale entries retain their existing translated value for reference until the AI agent updates them.
|