Skip to content

Blade rewriter misses short texts: no Commons namespace alias in its key map #3

Closed

Description

@ViniMayerFontana

Context

Laravel 13 + Inertia 2 + Vue 3.5 project; piloting the pipeline on Blade views
(resources/views/**).

What happens

extract routes short texts (≤ 2 words, ≤ 24 chars, no sentence punctuation) into a
Commons namespace. The Vue/JS replacement engine (src/i18n/replace-i18n.js,
buildKeyMap()) adds a Commons|kind|text alias (plus a text-kind fallback), so
those keys match from any file.

The Blade rewriter (src/i18n/rewrite-i18n-blade.js, buildKeyMapFromTranslations())
registers only the literal tree path — no Commons alias, no kind fallback. Any
Blade string short enough to land in Commons therefore never matches its own
file-derived namespace.

Repro

resources/views/reports/pallet.blade.php contains <title>Pallet Report</title>:

  • extract writes the key as Commons.text.pallet_report (correct per the short-text rule);
  • the rewriter looks up Reports.Pallet|text|Pallet Report (namespace derived from the
    file path) → miss → file unchanged (0 replacements), while longer texts in the same
    run (e.g. an error-page paragraph) are replaced fine.

Expected

The Blade key map mirrors the Vue/JS behavior: Commons alias + text-kind fallback.

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 tracking this down. #13 adds the Commons fallback to Blade rewriting, so short strings can be matched from their view namespace.

    The fix is in the PR and has regression coverage. It’s awaiting merge, so it isn’t in a release yet.

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