Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twenty-games-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Pass the metadata as variables for error localization
8 changes: 5 additions & 3 deletions packages/clerk-js/src/ui/localization/makeLocalizable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ export const useLocalizations = () => {
}

const { code, message, longMessage, meta } = (error || {}) as ClerkAPIError;
const { paramName = '' } = meta || {};
const { paramName = '', identifiers, emailAddresses } = meta || {};
Copy link
Member

@tmilewski tmilewski Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the example, not_allowed_access: '{{identifiers}} is not allowed to access this page!!!!!' - would this be confusing there are multiple identifiers (or emailsAddresses) returned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are always arrays with 1 or more items.

Yes, the error message needs to be agnostic on the "is"/"are" part.


if (!code) {
return '';
}

const metaArgsAsVariables = { identifiers: identifiers?.join(', '), emailAddresses: emailAddresses?.join(', ') };

return (
t(localizationKeys(`unstable__errors.${code}__${paramName}` as any)) ||
t(localizationKeys(`unstable__errors.${code}` as any)) ||
t(localizationKeys(`unstable__errors.${code}__${paramName}` as any, metaArgsAsVariables)) ||
t(localizationKeys(`unstable__errors.${code}` as any, metaArgsAsVariables)) ||
longMessage ||
message
);
Expand Down
Loading