Skip to content

Commit dc533b0

Browse files
committed
Revert localeIdentifier changes
1 parent ef03542 commit dc533b0

13 files changed

Lines changed: 13 additions & 34 deletions

File tree

‎packages/jest-preset/jest/mocks/NativeModules.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ const NativeModules = {
222222
forceRTL: jest.fn(() => false) as JestMockFn<$FlowFixMe, $FlowFixMe>,
223223
getConstants: (): $FlowFixMe => ({
224224
isRTL: false,
225-
localeIdentifier: 'en-US',
226225
}),
227226
},
228227
};

‎packages/react-native/Libraries/ReactNative/I18nManager.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ type I18nManagerConstants = {
1818
*/
1919
doLeftAndRightSwapInRTL: boolean,
2020
isRTL: boolean,
21-
localeIdentifier: string,
21+
localeIdentifier?: ?string,
2222
};
2323

2424
let i18nConstants: I18nManagerConstants = {
2525
doLeftAndRightSwapInRTL: false,
2626
isRTL: false,
27-
localeIdentifier: 'en-US',
2827
...NativeI18nManager?.getConstants(),
2928
};
3029

‎packages/react-native/Libraries/ReactNative/__tests__/I18nManager-test.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type {I18nManagerConstants} from '../NativeI18nManager';
1414

1515
const nativeConstants: I18nManagerConstants = {
1616
isRTL: false,
17-
localeIdentifier: 'en-US',
1817
};
1918

2019
const nativeModule = {
@@ -40,7 +39,6 @@ describe('I18nManager', () => {
4039
expect(I18nManager.getConstants()).toEqual({
4140
doLeftAndRightSwapInRTL: false,
4241
isRTL: true,
43-
localeIdentifier: 'en-US',
4442
});
4543
});
4644
});

‎packages/react-native/React/CoreModules/RCTI18nManager.mm‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,9 @@ - (NSDictionary *)getConstants
6060
{
6161
return @{
6262
@"isRTL" : @([[RCTI18nUtil sharedInstance] isRTL]),
63-
@"localeIdentifier" : [self _localeIdentifier],
6463
};
6564
}
6665
67-
// BCP 47 language tag (e.g. "en-US", "zh-Hans-CN"), the same format as Android and the web
68-
- (NSString *)_localeIdentifier
69-
{
70-
NSLocale *locale = [NSLocale currentLocale];
71-
NSMutableArray<NSString *> *subtags = [NSMutableArray arrayWithObject:locale.languageCode];
72-
73-
if (locale.scriptCode != nil) {
74-
[subtags addObject:locale.scriptCode];
75-
}
76-
if (locale.countryCode != nil) {
77-
[subtags addObject:locale.countryCode];
78-
}
79-
80-
return [subtags componentsJoinedByString:@"-"];
81-
}
82-
8366
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
8467
{
8568
return std::make_shared<NativeI18nManagerSpecJSI>(params);

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal class I18nManagerModule(context: ReactApplicationContext?) :
2626

2727
return mapOf(
2828
"isRTL" to I18nUtil.instance.isRTL(context),
29-
"localeIdentifier" to locale.toLanguageTag(),
29+
"localeIdentifier" to locale.toString(),
3030
)
3131
}
3232

‎packages/react-native/ReactNativeApi.d.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<db8dbe7c6e1f949c218ff7a64948ed96>>
7+
* @generated SignedSource<<f554ab7bb041b561f5b444241e3efe71>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -2470,7 +2470,7 @@ declare type I18nManager = typeof I18nManager
24702470
declare type I18nManagerConstants = {
24712471
doLeftAndRightSwapInRTL: boolean
24722472
isRTL: boolean
2473-
localeIdentifier: string
2473+
localeIdentifier?: string
24742474
}
24752475
declare interface IEventEmitter<
24762476
TEventToArgsMap extends Readonly<
@@ -5952,7 +5952,7 @@ export {
59525952
GestureResponderHandlers, // 75220e0c
59535953
HostComponent, // 6ae8255a
59545954
HostInstance, // 038429fb
5955-
I18nManager, // 2432113d
5955+
I18nManager, // 2728fc6d
59565956
IEventEmitter, // fbef6131
59575957
IOSKeyboardEvent, // e67bfe3a
59585958
IgnorePattern, // ec6f6ece

‎packages/react-native/src/private/specs_DEPRECATED/modules/NativeI18nManager.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod
1414

1515
export type I18nManagerConstants = {
1616
isRTL: boolean,
17-
localeIdentifier: string,
17+
localeIdentifier?: ?string,
1818
};
1919

2020
export interface Spec extends TurboModule {

‎packages/react-native/types_DEPRECATED/Libraries/ReactNative/I18nManager.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface I18nManagerStatic {
1515
*/
1616
doLeftAndRightSwapInRTL: boolean;
1717
isRTL: boolean;
18-
localeIdentifier: string;
18+
localeIdentifier?: string | null | undefined;
1919
};
2020
/**
2121
* @deprecated Has no effect. Set `RCTSupportsRTL` to `true` in Info.plist on

‎scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4800,7 +4800,7 @@ struct facebook::react::NativeI18nManagerI18nManagerConstantsBridging {
48004800
public static T types;
48014801
public static bool isRTLToJs(facebook::jsi::Runtime& rt, decltype(types.isRTL) value);
48024802
public static facebook::jsi::Object toJs(facebook::jsi::Runtime& rt, const T& value, const std::shared_ptr<facebook::react::CallInvoker>& jsInvoker);
4803-
public static facebook::jsi::String localeIdentifierToJs(facebook::jsi::Runtime& rt, decltype(types.localeIdentifier) value);
4803+
public static std::optional<facebook::jsi::String> localeIdentifierToJs(facebook::jsi::Runtime& rt, decltype(types.localeIdentifier) value);
48044804
}
48054805

48064806
template <typename T>

‎scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6624,7 +6624,7 @@ struct facebook::react::NativeI18nManagerI18nManagerConstantsBridging {
66246624
public static T types;
66256625
public static bool isRTLToJs(facebook::jsi::Runtime& rt, decltype(types.isRTL) value);
66266626
public static facebook::jsi::Object toJs(facebook::jsi::Runtime& rt, const T& value, const std::shared_ptr<facebook::react::CallInvoker>& jsInvoker);
6627-
public static facebook::jsi::String localeIdentifierToJs(facebook::jsi::Runtime& rt, decltype(types.localeIdentifier) value);
6627+
public static std::optional<facebook::jsi::String> localeIdentifierToJs(facebook::jsi::Runtime& rt, decltype(types.localeIdentifier) value);
66286628
}
66296629

66306630
template <typename T>
@@ -9281,7 +9281,7 @@ struct JS::NativeI18nManager::Constants::Builder {
92819281
}
92829282

92839283
struct JS::NativeI18nManager::Constants::Builder::Input {
9284-
protected RCTRequired<NSString*> localeIdentifier;
9284+
protected NSString* localeIdentifier;
92859285
protected RCTRequired<bool> isRTL;
92869286
}
92879287

0 commit comments

Comments
 (0)