# Locale Bundle Contract Gate (`bread-kim/locale-bundle-contract-gate`) Actor

Validate JSON and YAML locale bundles before release. Detect missing keys, plural, interpolation, type, and HTML drift, then export precise paths plus SARIF, JUnit, and Markdown reports for CI.

- **URL**: https://apify.com/bread-kim/locale-bundle-contract-gate.md
- **Developed by:** [bread kim](https://apify.com/bread-kim) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Locale Bundle Contract Gate

Locale Bundle Contract Gate is a deterministic Apify Actor that compares one reference JSON/YAML locale bundle with up to 20 candidates. It reports missing and extra keys, value-type changes, message-contract drift, locale-aware plural mistakes, and HTML element-structure drift. It never translates text and calls no AI or paid API.

The useful output is not merely a pass/fail bit. Every finding includes a readable key path, RFC 6901 JSON Pointer, expected/actual evidence when applicable, and a concrete repair action. The Actor writes the same authoritative record to the default dataset and the `OUTPUT` key, preserves every source as a key-value record with its SHA-256 hash, and emits `REPORT.SARIF`, `REPORT.JUNIT.XML`, and `REPORT.MD`.

### Message syntax is explicit

- `plain`: structure, types, keys, and optional HTML only. Braces have no message meaning.
- `i18next`: `{{name}}` interpolation plus `_one`, `_few`, `_many`, `_other`, and related suffix groups. Expected suffixes come from `Intl.PluralRules(candidateLocale)`, so Korean is not forced to copy English categories.
- `icu`: ICU MessageFormat parsing, argument-name/type checks, select branches, and candidate-locale plural/ordinal categories. `{{name}}` is never accidentally parsed as ICU when `i18next` is selected.

### Input

Paste content or provide a public HTTPS URL for the base and each candidate. Exactly one source is required per bundle. URL fields are intentionally plain text in the Apify schema; runtime validation separately enforces HTTPS, no credentials, port 443, public-only DNS answers, pinned request lookup, connected-socket verification, revalidation after every redirect, three redirects, 10 seconds, and 1 MiB per source.

See [examples/input.json](examples/input.json) and [examples/output.json](examples/output.json). The deterministic demo in [canary_input.json](canary_input.json) uses only inline content and requires no network.

### Local verification

```bash
npm ci --ignore-scripts
npm run preflight
docker build --pull=false -t locale-bundle-contract-gate:local .
docker run --rm --network none -e AUTOMATON_CONTAINER_SMOKE=1 locale-bundle-contract-gate:local
```

The smoke branch is selected only when `AUTOMATON_CONTAINER_SMOKE=1`; otherwise the Actor uses its bounded native storage adapter and requires Actor input. Tests include a real downstream CI experiment that runs deliberately broken and corrected fixture files through production analysis code.

### CI decision

With `failOn: "error"` (default), the Actor saves all reports first and then exits non-zero when error findings exist. `failOn: "never"` is useful when a downstream step reads `OUTPUT.status`. Warnings, currently extra keys, do not fail the gate.

### Honest comparison and limits

Resource limits are enforced before comparison output is stored: 20 candidates, 1 MiB per source, 8 MiB across sources, 25,000 JSON/YAML values, depth 40, 1,024 UTF-8 bytes per key, 4,096 bytes per rendered readable path or RFC 6901 path, and 2 MiB of cumulative expanded paths per parsed bundle. Source URLs are limited to 2,048 bytes and locale identifiers to 128 bytes.

Finding messages and expected/actual evidence are bounded; evidence over 4 KiB is represented by an explicit `truncated: true` preview with its original byte length and SHA-256, never as a complete value. The retained finding set obeys both `maxFindings` and a 256 KiB cumulative serialized-finding budget while complete per-locale and global error/warning counts are tracked independently. Thus `status` remains `FAIL` when an error is not retained. `OUTPUT`, SARIF, JUnit, and Markdown are each checked against a 1 MiB ceiling before any production storage write. A truncated report states how many findings it retained; aggregate counts remain authoritative.

The free [`@lingual/i18n-check`](https://github.com/lingualdev/i18n-check) already checks ICU/i18next JSON/YAML bundles, missing keys, and invalid keys, and is the better choice when installing a local CLI is acceptable. This Actor is not sold as a novel implementation of those checks. Its product-specific value is a hosted, bounded contract with retained source hashes, exact dual paths, three CI report formats, one stable dataset record, and Apify API/workflow consumption. It does not scan application source for unused keys, translate strings, judge language quality, support PO/XLIFF/ARB, or prove that rendered UI is correct.

Automated plural checks are contract policy, not linguistic proof. ICU mode expects the candidate locale's plural categories plus explicit numeric selectors found in the base. Teams that intentionally collapse categories should use `plain` mode or adapt their bundle before gating.

### Output contract

[tests/canary-output.schema.json](tests/canary-output.schema.json) is the authoritative JSON Schema for the `OUTPUT` record. Apify's input, output-link, and dataset schemas remain distinct platform contracts in [.actor](.actor). `actor.json` references the exact uploaded files.

### Privacy and cost

Inline runs make no network calls. URL mode fetches only URLs explicitly supplied by the user. No credentials, proxy, browser, paid API, webhook, schedule, or external AI is used. See [SECURITY_REVIEW.md](SECURITY_REVIEW.md), [PRICING_PROPOSAL.md](PRICING_PROPOSAL.md), and [SUPPORT.md](SUPPORT.md).

Release readiness is owned by the Automaton workflow and Portfolio, not a claim embedded in uploaded source. The local QA report records implementation checks; signed exact-bundle Docker validation and actual Private Build/Canary receipts must also pass before READY_TO_PUBLISH. Public visibility, Store publication, monetization and icon registration remain separately approved manual actions.

# Actor input Schema

## `baseLocale` (type: `string`):

Locale identifier for the reference bundle, for example en or en-US.

## `baseContent` (type: `string`):

Inline JSON or YAML reference bundle. Provide this or Base URL, but not both. Maximum 1048576 UTF-8 bytes.

## `baseUrl` (type: `string`):

Public HTTPS URL for the reference bundle. Credentials, private addresses, non-default ports, and unsafe redirects are rejected.

## `baseFormat` (type: `string`):

Parser for the base bundle. Auto selects JSON when the first non-space character is a brace or bracket; otherwise YAML.

## `messageSyntax` (type: `string`):

Explicit contract mode: plain skips message parsing, i18next checks double-brace interpolation and locale plural suffixes, and ICU parses ICU MessageFormat.

## `candidates` (type: `array`):

One to twenty translated bundles to compare against the base. Locale identifiers must be unique.

## `detectHtml` (type: `boolean`):

Compare ordered HTML start/end tag structure inside matching string values.

## `maxFindings` (type: `integer`):

Cap detailed findings while retaining authoritative total counts.

## `failOn` (type: `string`):

Error exits non-zero after saving reports when contract errors exist; Never always exits successfully.

## Actor input object example

```json
{
  "baseLocale": "en",
  "baseContent": "{\"welcome\":\"Hello {{name}}\",\"items_one\":\"One item\",\"items_other\":\"{{count}} items\"}",
  "baseFormat": "auto",
  "messageSyntax": "i18next",
  "candidates": [
    {
      "locale": "ko",
      "format": "json",
      "content": "{\"welcome\":\"{{name}}님 안녕하세요\",\"items_other\":\"{{count}}개\"}"
    }
  ],
  "detectHtml": true,
  "maxFindings": 500,
  "failOn": "error"
}
```

# Actor output Schema

## `results` (type: `string`):

The single dataset record described by the dataset schema.

## `outputRecord` (type: `string`):

The authoritative result in the default key-value store.

## `sarifReport` (type: `string`):

SARIF 2.1.0 findings for code-scanning integrations.

## `junitReport` (type: `string`):

JUnit XML findings for CI test-report integrations.

## `developerReport` (type: `string`):

Markdown report with exact key paths, JSON pointers, evidence hashes, and suggested actions.

## `sourceEvidence` (type: `string`):

Default key-value-store listing containing the exact downloaded or inline source bytes used by the run.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "baseContent": "{\"welcome\":\"Hello {{name}}\",\"items_one\":\"One item\",\"items_other\":\"{{count}} items\"}",
    "candidates": [
        {
            "locale": "ko",
            "format": "json",
            "content": "{\"welcome\":\"{{name}}님 안녕하세요\",\"items_other\":\"{{count}}개\"}"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("bread-kim/locale-bundle-contract-gate").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "baseContent": "{\"welcome\":\"Hello {{name}}\",\"items_one\":\"One item\",\"items_other\":\"{{count}} items\"}",
    "candidates": [{
            "locale": "ko",
            "format": "json",
            "content": "{\"welcome\":\"{{name}}님 안녕하세요\",\"items_other\":\"{{count}}개\"}",
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("bread-kim/locale-bundle-contract-gate").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "baseContent": "{\\"welcome\\":\\"Hello {{name}}\\",\\"items_one\\":\\"One item\\",\\"items_other\\":\\"{{count}} items\\"}",
  "candidates": [
    {
      "locale": "ko",
      "format": "json",
      "content": "{\\"welcome\\":\\"{{name}}님 안녕하세요\\",\\"items_other\\":\\"{{count}}개\\"}"
    }
  ]
}' |
apify call bread-kim/locale-bundle-contract-gate --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bread-kim/locale-bundle-contract-gate"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/BWmwcw0pbF7pBeRLk/builds/OgzYWMyJttqlfeIMm/openapi.json
