dhre-ui-kit 0.0.383 → 0.0.385

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 CHANGED
@@ -384,20 +384,16 @@ const CustomTypography = ({
384
384
  translateToArabic = false,
385
385
  ...props
386
386
  }) => {
387
- const [translatedText, setTranslatedText] = React.useState(text || "");
387
+ const [translatedText, setTranslatedText] = React.useState();
388
388
  const textStyle = FONT_STYLES[variant];
389
389
  React.useEffect(() => {
390
390
  const translateText = async () => {
391
- if (!translateToArabic || !text || text.trim() === "") {
392
- setTranslatedText(text || "");
393
- return;
394
- }
395
391
  try {
396
- const res = await translate__default["default"](text, { to: "ar" });
397
- setTranslatedText(res.text);
392
+ const res = await translate__default["default"](text ?? "", { to: "ar" });
393
+ setTranslatedText(translateToArabic ? res?.text : text);
398
394
  } catch (error) {
399
395
  console.error("Translation error:", error);
400
- setTranslatedText(JSON.stringify(error));
396
+ setTranslatedText(text);
401
397
  }
402
398
  };
403
399
  translateText();