gpt4 book ai didi

reactjs - 在 React Native 中本地化为 LTR 时使用 RTL 方向

转载 作者:行者123 更新时间:2023-12-05 06:23:25 24 4
gpt4 key购买 nike

我已经使用 i18n 在我的 React Native 应用程序中使用多种语言。

问题是当 Localization 设置基于 LTR 时,我无法将 TextInput 方向更改为 RTL。我试过 writingDirection 但它只适用于 IOS。我也尝试过 textAlign 但一无所获:(。

这是我的 i18n 设置和 TextInput 示例代码:

i18n.js

import { I18nManager } from 'react-native';
import * as Localization from 'expo-localization';
import i18n from 'i18n-js';
import fa from '../locales/fa';
import en from '../locales/en';

I18nManager.forceRTL(false);
Localization.locale = 'en';

i18n.fallbacks = true;
i18n.translations = { fa, en };
i18n.locale = Localization.locale;

export default i18n;

TextInput 示例代码

<TextInput
style={{textAlign: 'right'}} // here is the style that does'nt work.
label={i18n.t('signUp.surName')}
value={formData.surName.value}
onChangeText={(value) => changeHandler('surName', value)}
/>

enter image description here

最佳答案

我写了snack example,没发现问题: https://snack.expo.io/@djalik/text-input-align-right可能是您使用的是旧版本的 expo/react-native。

关于reactjs - 在 React Native 中本地化为 LTR 时使用 RTL 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58363749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com