0

My problem is when I create a multi-language app in react native, for example, an app that can be in Arabic and English. when I want to style a component to change the direction when language is switched I always use this type of styling

i18n.language == 'ar' ? 'row-reverse' : 'row',

I tried to use global styling to avoid repeating it in all Views but I can't call i18n outside a component. any solution to global the style for the languages?

I tried to use global styles but it did not work

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

you can use I18nManager

import { I18nManager } from 'react-native';

if (arabic)
  I18nManager.isRTL = true;
  I18nManager.allowRTL(true);
  I18nManager.forceRTL(true);
else
  ...

check language

if (I18nManager.isRTL) 
 ....
bagi2info.com
  • 408
  • 1
  • 3
  • 11