Guest User

Untitled

a guest
Nov 14th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import ReactNative from 'react-native';
  2. import I18n from 'react-native-i18n';
  3.  
  4. // Import all locales
  5. import en from './en.json';
  6. import he from './he.json';
  7.  
  8. // Should the app fallback to English if user locale doesn't exists
  9. I18n.fallbacks = true;
  10.  
  11. // Define the supported translations
  12. I18n.translations = {
  13. en,
  14. he
  15. };
  16.  
  17. const currentLocale = I18n.currentLocale();
  18.  
  19. // Is it a RTL language?
  20. export const isRTL = currentLocale.indexOf('he') === 0 || currentLocale.indexOf('ar') === 0;
  21.  
  22. // Allow RTL alignment in RTL languages
  23. ReactNative.I18nManager.allowRTL(isRTL);
  24.  
  25. // The method we'll use instead of a regular string
  26. export function strings(name, params = {}) {
  27. return I18n.t(name, params);
  28. };
  29.  
  30. export default I18n;
Add Comment
Please, Sign In to add comment