소스 검색

fix: translations with multiple transform matches

Sv443 1 일 전
부모
커밋
7f67cfb4d7
2개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 0
      .changeset/fruity-pens-shout.md
  2. 1 1
      lib/translation.ts

+ 5 - 0
.changeset/fruity-pens-shout.md

@@ -0,0 +1,5 @@
+---
+"@sv443-network/userutils": patch
+---
+
+Fixed compatibility for translations with multiple transform function matches

+ 1 - 1
lib/translation.ts

@@ -110,7 +110,7 @@ function translate<TTrKey extends string = string>(language: string, key: TTrKey
       const matches: RegExpExecArray[] = [];
       let execRes: RegExpExecArray | null;
       while((execRes = re.exec(trValue)) !== null) {
-        if(matches.some(m => m[0] === execRes?.[0]))
+        if(matches.some(m => m[0] === execRes?.[0] && m.index === execRes?.index))
           break;
         matches.push(execRes);
       }