l-min-components 1.7.1600 → 1.7.1601
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ import { LanguageDropdownContainer } from './index.styled';
|
|
|
9
9
|
import { RiCloseCircleFill } from 'react-icons/ri';
|
|
10
10
|
import { HiSearch } from 'react-icons/hi';
|
|
11
11
|
import { InputSearchIcon } from './assets/svg/search';
|
|
12
|
-
import
|
|
12
|
+
import DebounceInput from 'react-debounce-input';
|
|
13
13
|
import { languagesData } from './languages';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -45,30 +45,30 @@ const useTranslation = (initialSentences = []) => {
|
|
|
45
45
|
/**
|
|
46
46
|
* Send translation request to backend (fire-and-forget)
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
const sendTranslationRequestToBackend = async (language, words) => {
|
|
49
|
+
try {
|
|
50
|
+
// Fire-and-forget - don't await or use response
|
|
51
|
+
translate({
|
|
52
|
+
url: `/iam/v1/utils/translate_async/`,
|
|
53
|
+
data: {
|
|
54
|
+
language,
|
|
55
|
+
sentences: words,
|
|
56
|
+
},
|
|
57
|
+
params: {
|
|
58
|
+
_account: "",
|
|
59
|
+
},
|
|
60
|
+
headers: {
|
|
61
|
+
Authorization: "",
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
} catch (err) {
|
|
65
|
+
console.warn("Translation request failed:", err);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
* Fetch master translations from S3 with caching
|
|
71
|
+
*/
|
|
72
72
|
const getMasterTranslationsWithCache = async () => {
|
|
73
73
|
const now = Date.now();
|
|
74
74
|
const cached = window.translationCache.master;
|
|
@@ -119,19 +119,23 @@ const useTranslation = (initialSentences = []) => {
|
|
|
119
119
|
/**
|
|
120
120
|
* Extract relevant translations for specific texts
|
|
121
121
|
*/
|
|
122
|
-
const extractRelevantTranslations = (
|
|
122
|
+
const extractRelevantTranslations = (
|
|
123
|
+
// masterTranslations,
|
|
124
|
+
words,
|
|
125
|
+
language
|
|
126
|
+
) => {
|
|
123
127
|
const relevantTranslations = {};
|
|
124
128
|
const languageCode = language.toUpperCase(); // ko -> KO, fr -> FR
|
|
125
129
|
|
|
126
130
|
words.forEach((word) => {
|
|
127
|
-
if (masterTranslations[word] && masterTranslations[word][languageCode]) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
} else {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
131
|
+
// if (masterTranslations[word] && masterTranslations[word][languageCode]) {
|
|
132
|
+
// const translation = masterTranslations[word][languageCode];
|
|
133
|
+
// // Only use translation if it's not empty
|
|
134
|
+
// relevantTranslations[word] = translation.trim() || word;
|
|
135
|
+
// } else {
|
|
136
|
+
// Return original text if translation not found
|
|
137
|
+
relevantTranslations[word] = word;
|
|
138
|
+
// }
|
|
135
139
|
});
|
|
136
140
|
|
|
137
141
|
return relevantTranslations;
|
|
@@ -148,11 +152,11 @@ const useTranslation = (initialSentences = []) => {
|
|
|
148
152
|
// sendTranslationRequestToBackend(language, words);
|
|
149
153
|
|
|
150
154
|
// Step 2: Get master translations (cached or fresh from S3)
|
|
151
|
-
const masterTranslations = await getMasterTranslationsWithCache();
|
|
155
|
+
// const masterTranslations = await getMasterTranslationsWithCache();
|
|
152
156
|
|
|
153
157
|
// Step 3: Extract only the translations we need
|
|
154
158
|
const relevantTranslations = extractRelevantTranslations(
|
|
155
|
-
masterTranslations,
|
|
159
|
+
// masterTranslations,
|
|
156
160
|
words,
|
|
157
161
|
language
|
|
158
162
|
);
|