Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 22x 22x 22x 22x 22x 2667x 41x 2626x 22x 57x 57x 57x 22x 14x 14x 30x 30x 2610x 13x 13x 20x | /**
* Copyright (c) Nicolas Gallagher.
* 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
*/
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
type I18nManagerStatus = {
allowRTL: (allowRTL: boolean) => void,
forceRTL: (forceRTL: boolean) => void,
getConstants: () => Constants,
setPreferredLanguageRTL: (setRTL: boolean) => void,
swapLeftAndRightInRTL: (flipStyles: boolean) => void
};
type Constants = {
doLeftAndRightSwapInRTL: boolean,
isRTL: boolean
};
let doLeftAndRightSwapInRTL = true;
let isPreferredLanguageRTL = false;
let isRTLAllowed = true;
let isRTLForced = false;
const isRTL = () => {
if (isRTLForced) {
return true;
}
return isRTLAllowed && isPreferredLanguageRTL;
};
const onDirectionChange = () => {
Eif (ExecutionEnvironment.canUseDOM) {
Eif (document.documentElement && document.documentElement.setAttribute) {
document.documentElement.setAttribute('dir', isRTL() ? 'rtl' : 'ltr');
}
}
};
const I18nManager: I18nManagerStatus = {
allowRTL(bool) {
isRTLAllowed = bool;
onDirectionChange();
},
forceRTL(bool) {
isRTLForced = bool;
onDirectionChange();
},
getConstants(): Constants {
return { doLeftAndRightSwapInRTL, isRTL: isRTL() };
},
setPreferredLanguageRTL(bool) {
isPreferredLanguageRTL = bool;
onDirectionChange();
},
swapLeftAndRightInRTL(bool) {
doLeftAndRightSwapInRTL = bool;
}
};
export default I18nManager;
|