Skip to content

Commit

Permalink
WEB-2079 minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Ladaria committed Nov 13, 2024
1 parent b5bd484 commit 4ebc6d7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/theme-context-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ const ThemeContextProvider = ({theme, children, as, withoutStyles = false}: Prop
const translate = React.useCallback(
(token: TextToken, ...params: Array<string | number>): string => {
const text = token[language] || token.en;
if (!params.length) {
return text;
}
// replace token parameters: 1$s, 2$s, 3$s, etc.
return text.replace(/\d+\$s/g, (substr) => {
return String(params[parseInt(substr) - 1] ?? substr);
Expand Down

0 comments on commit 4ebc6d7

Please sign in to comment.