ek9_extract_to_localized_text

Replaces the selected string literal with `<localeAccessor>.<name>(args)` and adds the text method to every locale of the i18n file in one atomic changeset, answering the editor envelope: status (applied | ready | would-fail | conflicts | error), written, edits[], summary and translationDebt[] naming the locales left placeholder-stubbed.

Category: Editor · Compare: NEW IDE surface — Right-click on a selected string literal (double-quoted or backtick-interpolation) inside an EK9 source file → "Extract to Localized Text…"

When to use it

'Move this hard-coded user-facing string into the i18n text type' is one call: {file, startLine, startColumn, endLine, endColumn (1-based) over the literal, textTypeName, name, localeAccessor}.

When not to use it

Details

Parameter inference from `${...}`: simple ref → symbol name+type; property access (${p.x}) → receiver name+type; method call (${items.size()}) → return-type heuristic ('count'), receiver-name fallback - a parameters override must match the inferred COUNT and ORDER (types can widen, names can differ). textTypeName discovery is cross-module — resolved through the module's references block, so a centralized text type is found and extended, not duplicated. Conflicts are all mechanical and caller-repairable — notably selection-is-concat-not-literal (run ek9_rewrite_string_concat first), no-text-type-instance-in-scope, and i18n-file-supplied-for-existing-text-type (drop i18nFile — the existing block locations govern); when the type already spans multiple locales an omitted primaryLocale silently defaults to the first locale, so supply it. translationDebt[] lists the non-primary locales stubbed with the primary body plus an //AI: translate directive.

Arguments

ArgumentTypeRequiredWhat it is
endColumninteger1-based column of the literal's closing quote or backtick, inclusive.
endLineinteger1-based line the literal ends on (the same line for a one-line literal).
filestringyesThe .ek9 source file holding the literal - workspace-relative (absolute inside the workspace accepted).
i18nFilestringDestination: required when textTypeName does NOT yet exist in the module. Workspace-relative path where the new text type lands.
localeAccessorstringyesName of an existing variable in scope at the selection site whose type is the target text type. The rewritten call site becomes `<localeAccessor>.<name>(<args>)`.
namestringyesName for the new text method.
parametersarray of anyOptional override of the auto-inferred parameter signature. Supplied parameters must match the inferred count AND order; names can differ; types can widen.
primaryLocalestringRequired when textTypeName does NOT yet exist. Strongly recommended whenever the text type already exists in multiple locales.
selectionobjectIDE alias for the four flat keys: {startLine, startCol, endLine, endCol}, 1-based inclusive.
startColumninteger1-based column of the literal's opening quote or backtick, inclusive.
startLineinteger1-based line the string literal starts on.
supportedLocalesarray of stringOptional for new text type creation.
textTypeNamestringyesTarget text type (PascalCase). If it exists in the module, the method is added via add-text-method semantics internally. If it does not exist, the tool creates it.

It also takes the arguments every tool takes.

See also