android - 如何在 iOS 中使用 EXPO/react-native 实现 RTL
问题描述
我在我的反应原生应用程序文件名中添加了两个本地化文件(阿拉伯语和英语),如ar.json和en.json。
我的en.json文件看起来像
"fieldNames": {
"enterEmail" : "Enter the email address"
},
我的ar.json文件看起来像
"fieldNames": {
"enterEmail" : "أدخل عنوان البريد الإلكتروني"
},
我的string/index.js文件如下所示:
import * as Localization from 'expo-localization';
import i18n from 'i18n-js';
import en from './en.json';
import ar from './ar.json';
i18n.fallbacks = true;
i18n.translations = { en, ar };
i18n.locale = Localization.locale;
export const string = value => i18n.t(value);
export default i18n;
我使用的文件之一如下
<Text>{string('fieldNames.enterEmail')}</Text>
本地化适用于两种语言。
但是当我选择阿拉伯语时,它不会与 iOS 中的右侧对齐。
在我的 android 设备中,它工作正常。此问题仅出现在 iOS 中。
你能帮我解决这个问题吗
解决方案
RTL 与 Localization(l10n) 无关。相反,Internalization(i18n) 确实如此。
如果您使用start
andright
前缀而不是left
and right
,那么您的 RTL 将被实现。
例如,您可以使用marginStart
代替marginLeft
RTL
推荐阅读
- mysql - 从同一列中选择多个相同的值行
- google-cloud-platform - 在 Google Cloud Build 中运行 Cypress
- python - 如何在两个数据帧之间的 np.where 中避免 NaN?
- c# - C# 反射,Reflection.TargetException,当调用 ToString(IFormatProvider)
- r - sort() 工作正常,但使用它来显示完整的排序数据框会给出不同的输出,而不是排序后的输出
- vba - 从 Access VBA 查询 Outlook 全局地址列表
- ios - 为 iOS 构建 OpenCV 静态库
- java - 从Java中的另一个类静态实例化泛型父类的子类
- javascript - 如何使用 jQuery 为数组中的每个元素插入额外的 JS 脚本?
- javascript - 是否有事件以角度检测模板元素上的类属性更改?