Repository navigation
fix(@inquirer/i18n): let the user theme override locale defaults - #2371
Merged
SBoudrias merged 2 commits intoOct 31, 2026
Merged
Conversation
The localized select, checkbox, search, editor and password wrappers merged the locale strings after `config.theme`, so a user's `keysHelpTip`, `maskedText`, `waitingMessage` or `loadingMessage` was replaced by the locale one. Merge the locale strings first so they act as defaults, matching how `@inquirer/prompts` honors the theme.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2371 +/- ##
=======================================
Coverage ? 94.89%
=======================================
Files ? 48
Lines ? 2430
Branches ? 645
=======================================
Hits ? 2306
Misses ? 123
Partials ? 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…bels - confirm: locale keywords are defaults, config.theme overrides them - keysHelpTip: custom formatters now receive the translated labels (the user formatter, or the built-in layout when none is given); returning undefined still hides the help line - docs: document the theme/locale split, fix the custom-locale example (missing invalidAnswer and helpToggle)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The localized
select,checkbox,search,editorandpasswordwrappers calledmakeTheme(config.theme, { style: { ...locale } }), so the locale strings were merged last and replaced what the user passed. With@inquirer/i18n/zh(or the root import under a non-English locale),keysHelpTip: () => undefinedno longer hides the help line, a customkeysHelpTipformatter is never called, andmaskedText,waitingMessageandloadingMessageare ignored. The same code works with@inquirer/promptsand theenlocale.This merges the locale strings first and
config.themesecond, so they act as defaults. Keys the user does not set stay localized (the zh password help line is stillctrl+t 切换可见性). A customkeysHelpTipreceives the English labels, as it does with@inquirer/prompts; if you'd rather pass it the translated labels, I can switch to that. I leftconfirmas is; itskeywordscould get the same treatment if wanted.yarn vitest --run packages/i18n(67 passed; the 2 new tests fail on main),yarn vitest --run packages(539 passed, 1 skipped)yarn tsc,yarn oxlint .,yarn eslint .,yarn oxfmt --check packages/i18n, all clean