Files
react-native/Libraries/ReactNative/I18nManager.js
T
Andrew Coates 6b91ae73cd localeIdentifier missing from flow type of I18nManager (#31589)
Summary:
https://github.com/facebook/react-native/commit/23d9bf1a24f80003a8a3c0b82e9b5691e4e6544e looks like it accidently removed `localeIdentifier` from I18nManager.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - Re-added localeIdentifier to I18nManager constants

Pull Request resolved: https://github.com/facebook/react-native/pull/31589

Reviewed By: GijsWeterings

Differential Revision: D28690202

Pulled By: fkgozali

fbshipit-source-id: 543a491f89789bca5629e1251c94fd055ec4a801
2021-05-26 00:04:19 -07:00

71 lines
1.4 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import NativeI18nManager from './NativeI18nManager';
const i18nConstants: {|
doLeftAndRightSwapInRTL: boolean,
isRTL: boolean,
localeIdentifier?: ?string,
|} = getI18nManagerConstants();
function getI18nManagerConstants() {
if (NativeI18nManager) {
const {
isRTL,
doLeftAndRightSwapInRTL,
localeIdentifier,
} = NativeI18nManager.getConstants();
return {isRTL, doLeftAndRightSwapInRTL, localeIdentifier};
}
return {
isRTL: false,
doLeftAndRightSwapInRTL: true,
};
}
module.exports = {
getConstants: (): {|
doLeftAndRightSwapInRTL: boolean,
isRTL: boolean,
localeIdentifier: ?string,
|} => {
return i18nConstants;
},
allowRTL: (shouldAllow: boolean) => {
if (!NativeI18nManager) {
return;
}
NativeI18nManager.allowRTL(shouldAllow);
},
forceRTL: (shouldForce: boolean) => {
if (!NativeI18nManager) {
return;
}
NativeI18nManager.forceRTL(shouldForce);
},
swapLeftAndRightInRTL: (flipStyles: boolean) => {
if (!NativeI18nManager) {
return;
}
NativeI18nManager.swapLeftAndRightInRTL(flipStyles);
},
isRTL: i18nConstants.isRTL,
doLeftAndRightSwapInRTL: i18nConstants.doLeftAndRightSwapInRTL,
};