Skip to content

fix: skip already-translated keys in spark lang:find#10308

Merged
paulbalandan merged 1 commit into
codeigniter4:developfrom
paulbalandan:lang-find-resolved-keys
Jun 12, 2026
Merged

fix: skip already-translated keys in spark lang:find#10308
paulbalandan merged 1 commit into
codeigniter4:developfrom
paulbalandan:lang-find-resolved-keys

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description

spark lang:find decided whether a key was "new" by loading only app/Language/<locale>/<File>.php. But at runtime lang() resolves a key through the FileLocator across every namespace (framework, packages, and app). As a result, keys already shipped by the framework or a package (for example Errors.* from system/Language) were treated as new:

  • --show-new listed them as missing translations.
  • In write mode they were materialized into app/Language as untranslated placeholders (the dotted key string), which then overrode the framework's real translations at runtime (e.g. error pages rendering the literal Errors.pageNotFound).

This PR makes the finder compare found keys against the translations resolvable from all namespaces, mirroring how lang() resolves at runtime. A key is now considered new only when it cannot be resolved from any loaded language file. Write mode writes only genuinely-new keys plus the app's own existing keys, so framework- or package-provided translations are never copied into app/Language.

Added regression tests for both the --show-new and write paths, and a note in the localization guide.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@paulbalandan paulbalandan added the bug Verified issues on the current code behavior or pull requests that will fix them label Jun 12, 2026
@paulbalandan paulbalandan merged commit dd409ab into codeigniter4:develop Jun 12, 2026
57 checks passed
@paulbalandan paulbalandan deleted the lang-find-resolved-keys branch June 12, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants