Skip to content

Commit

Permalink
Single argument isn't correctly replaced
Browse files Browse the repository at this point in the history
Fixes #21
  • Loading branch information
Luis Fernando Planella Gonzalez committed May 5, 2023
1 parent 8919a2d commit 4d0c188
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions static/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const proxyHandler: ProxyHandler<any> = {
const result = (...args: any[]) => {
// When invoked as a function, replace parameters
return translated.replace(/\{\w+\}/g, (substring: string) => {
if (args.length === 1 && typeof args[0] !== 'object') {
return String(args[0]);
}
const paramName = substring.substring(1, substring.length - 1);
if (/[0-9]+/.test(paramName)) {
return String(args[parseInt(paramName, 10)]);
Expand Down

0 comments on commit 4d0c188

Please sign in to comment.