在没有 forceRTL 的情况下反应本地阿拉伯语 (RTL) [英] React Native Arabic (RTL) without forceRTL

查看:42
本文介绍了在没有 forceRTL 的情况下反应本地阿拉伯语 (RTL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 RN 我的双语应用程序(英语 - 阿拉伯语)中,我使用了 I18nManager(视图)和 I18n(用于翻译)

In RN my bilingual app (English - Arabic), I have used I18nManager (views) and I18n (for translations)

当我将应用程序语言更改为阿拉伯语时,使用以下代码从启动画面再次重新加载整个应用程序:

When I am changing app language to Arabic, the whole app gets reloaded again from the splash-screen using this code:

I18nManager.forceRTL(true)

理想情况下,它不应从头开始重新启动应用程序,而应继续使用阿拉伯数据显示当前屏幕.

Ideally, it should not restart the app from start and it should continue with the current screen with Arabic data.

目前,它没有发生,只有翻译元素使用 I18n.t('keyword') 进行转换,但对于视图阿拉伯语对齐,这是不正确的.

Currently, it is not happening, only translation elements are getting converted using I18n.t('keyword') but for views Arabic alignment, it's not proper.

仍在寻找更好的解决方案,如果有人实现了,请告诉我.

Still looking for a better solution, let me know if anyone achieved it.

谢谢
索普!!

推荐答案

你应该把这段代码放在你项目的最顶层

you should put this code in the top component in your project

import RNRestart from "react-native-restart";

I18nManager.forceRTL(true);if (!I18nManager.isRTL) RNRestart.Restart();

这篇关于在没有 forceRTL 的情况下反应本地阿拉伯语 (RTL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆