Skip to content

Extract turns select option values into translation keys — risks rewriting value: 'x' into value: t('...') #7

Closed

Description

@ViniMayerFontana

What happens

In a Vue SFC, an inline options array like

const typeOptions = [
  { value: 'weight', label: 'Weight' },
  { value: 'other',  label: 'Other'  },
];

gets its option VALUE ('other', a machine identifier persisted to the database via
v-model) extracted as a translatable string — it landed in the base locale as
Commons.text.other: "other", while the label correctly became
Commons.text.other_2: "Other".

The replace phase did not rewrite it in our run, but the key map contains
Commons|text|other, so a script-side string-literal replacement pass that matches
object property values could rewrite value: 'other' into value: t('Commons.text.other')
— which would silently change the data written by v-model and break stored records.
This makes every extract run on a codebase with inline option arrays a latent
data-corruption risk, not just a cosmetic false positive.

Expected

Exclude string literals assigned to common value-like property names
(value, id, key, slug, type?) from extraction — or apply the code validators
(validateText) to script object-literal property values, the same way the Blade path
lacks validators (see our earlier report).

Workaround used

Verbatim translation for the false-positive key (translation value == source string)
and per-batch diff review.

Environment

@ai-localizer/cli / @ai-localizer/core v0.1.1 (patched replacers; extractor unmodified
from HEAD 6d478b3), Windows 11, Node v24.20.0, Laravel 13 + Inertia 2 + Vue 3.5.

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 highlighting the data risk. #13 excludes common machine-value properties from Vue script extraction, while keeping display labels eligible for translation.

    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