Skip to content

Blade extract/replace lack code validation — shell commands become translation keys #5

Closed

Description

@ViniMayerFontana

What happens

The Blade phases validate with ignore patterns only (shouldIgnoreText); the
validators used by the Vue/JS path (src/i18n/lib/validators) are not applied. In our
pilot, the extractor accepted the shell command docker compose up -d inside
<pre>docker compose up -d</pre> and the rewriter then produced:

<pre>{{ __("Errors.TurnstileMisconfigured.text.docker_compose_up_d") }}</pre>

— a shell command became a translation key.

Related observation: text fragments adjacent to inline tags in paragraphs containing
<code> (e.g. — set, ; then run:, , and set both) are extracted as standalone
keys, but their parent paragraphs are skipped by the rewriter (tags inside), so those
fragments can never be rendered in context.

Expected

Apply validateText/code validation to the Blade extract and replace phases — at
minimum skip <pre> content and command/config-looking strings. For fragments
adjacent to inline elements, either skip them or make the rewriter handle the parent
paragraph.

Workaround used

Human review of the replace diff per batch + verbatim answers (translation value ==
source string) for false-positive keys.

Environment

@ai-localizer/cli / @ai-localizer/core v0.1.1, Windows 11, Node v24.20.0.

Happy to contribute a PR (Apache-2.0).


Reported by @ViniMayerFontana via the Relief Inventory pt-BR localization effort (Apache-2.0, happy to PR).

Activity

  1. xwiz commented on Nov 14, 2026

    @xwiz
    Contributor

    Thanks for the detailed report. #13 protects <pre>, <code>, scripts, styles and comments during Blade extraction and rewriting, and avoids the inline fragments in your example. Those cases have regression tests.

    I’m keeping this open for now: the general validator can still accept some shell commands outside protected blocks. The PR is also awaiting merge and isn’t in a release yet.

  2. xwiz commented on Nov 14, 2026

    @xwiz
    Contributor

    Following up: #13 now filters common shell-command and environment-assignment shapes during Blade extraction and rewriting, including outside <pre> and <code>. It also keeps ordinary instructional sentences translatable, and includes regression tests for both paths.

    I’m closing this based on the fix in the PR. The PR is still awaiting merge, so it isn’t in a release yet; the filter is deliberately conservative rather than a complete shell parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions