I18nManager.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @flow strict-local
  8. * @format
  9. */
  10. 'use strict';
  11. import NativeI18nManager from './NativeI18nManager';
  12. const i18nConstants: {|
  13. doLeftAndRightSwapInRTL: boolean,
  14. isRTL: boolean,
  15. |} = NativeI18nManager
  16. ? NativeI18nManager.getConstants()
  17. : {
  18. isRTL: false,
  19. doLeftAndRightSwapInRTL: true,
  20. };
  21. module.exports = {
  22. getConstants: (): {|doLeftAndRightSwapInRTL: boolean, isRTL: boolean|} => {
  23. return i18nConstants;
  24. },
  25. allowRTL: (shouldAllow: boolean) => {
  26. if (!NativeI18nManager) {
  27. return;
  28. }
  29. NativeI18nManager.allowRTL(shouldAllow);
  30. },
  31. forceRTL: (shouldForce: boolean) => {
  32. if (!NativeI18nManager) {
  33. return;
  34. }
  35. NativeI18nManager.forceRTL(shouldForce);
  36. },
  37. swapLeftAndRightInRTL: (flipStyles: boolean) => {
  38. if (!NativeI18nManager) {
  39. return;
  40. }
  41. NativeI18nManager.swapLeftAndRightInRTL(flipStyles);
  42. },
  43. isRTL: i18nConstants.isRTL,
  44. doLeftAndRightSwapInRTL: i18nConstants.doLeftAndRightSwapInRTL,
  45. };