@@ -64,17 +64,15 @@ const changeImage = (imgElement, from, to) => {
6464 * @param {string } text - The input text to be translated.
6565 * @returns {string } The translated text.
6666 */
67- function _ ( text ) {
67+ function _ ( text , options = { } ) {
6868 if ( ! text ) return "" ;
6969
7070 try {
71- // Characters to remove
7271 const removeChars = [
7372 "," , "(" , ")" , "?" , "¿" , "<" , ">" , "." , "\n" , '"' ,
7473 ":" , "%s" , "%d" , "/" , "'" , ";" , "×" , "!" , "¡"
7574 ] ;
7675
77- // Remove unwanted characters from `text`
7876 let cleanedText = text ;
7977 for ( let char of removeChars ) {
8078 cleanedText = cleanedText . split ( char ) . join ( "" ) ;
@@ -86,48 +84,39 @@ function _(text) {
8684
8785 if ( lang . includes ( "kanji" ) || lang . includes ( "kana" ) ) {
8886 subLang = lang . includes ( "kana" ) ? "=)kana" : "=)kanji" ;
89- translated = i18next . t ( `${ text } ${ subLang } ` ) ;
87+ translated = i18next . t ( `${ text } ${ subLang } ` , options ) ;
9088 if ( translated === `${ text } ${ subLang } ` ) {
91- translated = i18next . t ( text ) ;
89+ translated = i18next . t ( text , options ) ;
9290 }
9391 }
94- else
95- {
96- translated = i18next . t ( text ) ;
92+ else {
93+ translated = i18next . t ( text , options ) ;
9794 }
9895
99-
100-
10196 if ( translated && translated === text ) {
10297 return translated ;
10398 }
10499
105- // Try cleaned text (without special characters, but still with spaces)
106100 if ( ! translated || translated === text ) {
107- translated = i18next . t ( cleanedText ) ;
101+ translated = i18next . t ( cleanedText , options ) ;
108102 }
109103
110- // Try lowercase
111104 if ( ! translated || translated === text ) {
112- translated = i18next . t ( text . toLowerCase ( ) ) ;
105+ translated = i18next . t ( text . toLowerCase ( ) , options ) ;
113106 }
114107
115- // Try title case
116108 if ( ! translated || translated === text ) {
117109 const titleCase = text . charAt ( 0 ) . toUpperCase ( ) + text . slice ( 1 ) . toLowerCase ( ) ;
118- translated = i18next . t ( titleCase ) ;
110+ translated = i18next . t ( titleCase , options ) ;
119111 }
120112
121- // Only as a LAST RESORT, try replacing spaces with hyphens
122113 let hyphenatedText = cleanedText . replace ( / / g, "-" ) ;
123114 if ( ! translated || translated === text ) {
124- translated = i18next . t ( hyphenatedText ) ;
115+ translated = i18next . t ( hyphenatedText , options ) ;
125116 }
126117
127- // If no translation is found, return the original text
128118 translated = translated || text ;
129119
130- // Maintain correct letter casing
131120 if ( text === text . toUpperCase ( ) ) {
132121 return translated . toUpperCase ( ) ;
133122 } else if ( text === text . toLowerCase ( ) ) {
@@ -144,6 +133,7 @@ function _(text) {
144133
145134
146135
136+
147137/**
148138 * A string formatting function using placeholder substitution.
149139 * @function
@@ -1185,7 +1175,7 @@ readable-fractions/681534#681534
11851175
11861176 let df = 1.0 ;
11871177 let top = 1 ;
1188- let iterations = 0 ;
1178+ let iterations = 0
11891179 const maxIterations = 10000 ;
11901180 let bot = 1 ;
11911181
0 commit comments