Skip to content

VueReplacer stops at the first inner </template> — near-zero coverage on slot-based SFCs #2

Closed

Description

@ViniMayerFontana

Context

Laravel 13 + Inertia 2 + Vue 3.5 project (134 SFCs; most CRUD pages render a shared
form component through named slots — #header, #listactions, #thead, #tbody,
#default). Running the extract/replace pipeline against one pilot page.

What happens

In @ai-localizer/core src/i18n/lib/replacers/vueReplacer.js, replace() isolates
the template with:

const templateMatch = content.match(/(<template[^>]*>)([\s\S]*?)(<\/template>)/i);

The [\s\S]*? is non-greedy, so the match ends at the first </template> —
which in slot-based components is an inner slot template (<template #header>...),
not the component's own template block. Everything after it is never processed.

Note the asymmetry: extraction scans the whole SFC (we got keys for strings that
live inside slots — e.g. a field label inside <template #default>), so the key map
already contains the strings the replacer then never looks at in that region.

Repro

<template>
  <Head title="Item Category Entry" />
  <SomeForm
    title="Item Category Management"
    newrecordcaption="Add Category">
    <template #listactions>
      <input placeholder="Search by Category Name..." />
    </template>
    <template #default>
      <div class="ri_fieldlabel">Category Name:</div>
    </template>
  </SomeForm>
</template>

ai-localize extract → ai-localize replace:

  • Actual: only <Head title="Item Category Entry" /> is replaced (it sits before the
    first inner </template>). 1 of 5 extracted strings rewritten; the other 4 —
    including title="Item Category Management" and placeholder="Search by Category Name...", whose keys ARE in the base locale — stay hard-coded.
  • Expected: the whole outer template block is processed (match the outermost
    </template>, or parse top-level SFC blocks properly).

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 clear reproduction. #13 handles the full outer Vue template, including nested slots, and adds coverage for content after the first slot and component caption attributes.

    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