Support localizable command palette copy#46
Conversation
Expose a messages prop so consumers can localize package-owned palette copy without adding an i18n dependency to the library.
|
I think this approach of i18n adds maintenance overhead: the clients have to pass every string-label. Can we just have the client pass the Or just directly use the |
@aswasif007 The boilerplate concern is fair and even considered it, but both alternatives run into practical issues: Passing the translate function: The main problem is string extraction. Tools like wp-i18n and Calypso's babel plugin work by statically analysing source code for Using i18n-calypso directly: This couples a reusable package to the Calypso ecosystem. VIP Dashboard already had to fork i18n-calypso locally just for React 18 compat. Future consumers may use entirely different i18n runtimes. Since it's That said, this felt like a straightforward fix without needing to add translation parsers or i18n dependencies to the package. But if you think a different approach would be worth the added complexity, happy to explore it further. |
Summary
Adds a dependency-free
messagesAPI so consumers can localize package-owned command palette copy while keeping their existing i18n framework.Closes RSM-2861
What changed
CommandsMessagesandResultItemTypeexports.messages?: Partial<CommandsMessages>to<Commands />.placeholderandemptyStateprecedence for backward compatibility.Testing
pnpm format:checkpnpm lintpnpm test -- src/commands.test.tsx