dhre-ui-kit 0.0.374 → 0.0.376
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/lib/index.js +20 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +19 -1
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -1
package/lib/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { createContext, useContext, useState, useEffect, useRef, memo, useCallback } from 'react';
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import { Dimensions, StyleSheet, Text, Pressable, View, Platform, KeyboardAvoidingView, TextInput, ScrollView, Animated, FlatList, TouchableOpacity, Modal as Modal$1, Alert, Linking, PanResponder } from 'react-native';
|
|
4
|
+
import translate from 'google-translate-api-x';
|
|
4
5
|
import Modal from 'react-native-modal';
|
|
5
6
|
import Clipboard from '@react-native-clipboard/clipboard';
|
|
6
7
|
import LottieView from 'lottie-react-native';
|
|
@@ -345,7 +346,24 @@ const CustomTypography = ({
|
|
|
345
346
|
testID = "CUSTOM_TYPOGRAPHY",
|
|
346
347
|
...props
|
|
347
348
|
}) => {
|
|
349
|
+
const [translatedText, setTranslatedText] = useState(text || "");
|
|
348
350
|
const textStyle = FONT_STYLES[variant];
|
|
351
|
+
useEffect(() => {
|
|
352
|
+
const translateText = async () => {
|
|
353
|
+
if (!text || text.trim() === "") {
|
|
354
|
+
setTranslatedText(text || "");
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
const res = await translate(text, { to: "ar" });
|
|
359
|
+
setTranslatedText(res.text);
|
|
360
|
+
} catch (error) {
|
|
361
|
+
console.error("Translation error:", error);
|
|
362
|
+
setTranslatedText(text);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
translateText();
|
|
366
|
+
}, [text]);
|
|
349
367
|
return /* @__PURE__ */ React.createElement(
|
|
350
368
|
Text,
|
|
351
369
|
{
|
|
@@ -353,7 +371,7 @@ const CustomTypography = ({
|
|
|
353
371
|
style: [textStyle, styles$B.container, style],
|
|
354
372
|
...props
|
|
355
373
|
},
|
|
356
|
-
|
|
374
|
+
translatedText
|
|
357
375
|
);
|
|
358
376
|
};
|
|
359
377
|
const styles$B = StyleSheet.create({
|