diff --git a/.changeset/twenty-games-repair.md b/.changeset/twenty-games-repair.md new file mode 100644 index 00000000000..56279d4158d --- /dev/null +++ b/.changeset/twenty-games-repair.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Pass the metadata as variables for error localization diff --git a/packages/clerk-js/src/ui/localization/makeLocalizable.tsx b/packages/clerk-js/src/ui/localization/makeLocalizable.tsx index 8b33139ea34..f74465c1b0e 100644 --- a/packages/clerk-js/src/ui/localization/makeLocalizable.tsx +++ b/packages/clerk-js/src/ui/localization/makeLocalizable.tsx @@ -89,15 +89,17 @@ export const useLocalizations = () => { } const { code, message, longMessage, meta } = (error || {}) as ClerkAPIError; - const { paramName = '' } = meta || {}; + const { paramName = '', identifiers, emailAddresses } = meta || {}; 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 );