File tree 6 files changed +27
-11
lines changed
android/src/main/java/com/zoontek/rnlocalize 6 files changed +27
-11
lines changed Original file line number Diff line number Diff line change 3
3
import android .annotation .SuppressLint ;
4
4
import android .content .ContentResolver ;
5
5
import android .content .res .Configuration ;
6
+ import android .icu .number .LocalizedNumberFormatter ;
7
+ import android .icu .number .NumberFormatter ;
8
+ import android .icu .util .MeasureUnit ;
6
9
import android .os .Build ;
7
10
import android .provider .Settings ;
8
11
import android .text .TextUtils ;
@@ -229,6 +232,23 @@ public class RNLocalizeModuleImpl {
229
232
}
230
233
231
234
public static @ NonNull String getTemperatureUnit (ReactApplicationContext reactContext ) {
235
+ // https://github.com/androidx/androidx/blob/androidx-main/core/core/src/main/java/androidx/core/text/util/LocalePreferences.java
236
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
237
+ Locale systemLocale = getSystemLocale (reactContext );
238
+
239
+ LocalizedNumberFormatter formatter = NumberFormatter .with ()
240
+ .usage ("weather" )
241
+ .unit (MeasureUnit .CELSIUS )
242
+ .locale (systemLocale );
243
+
244
+ String unit = formatter
245
+ .format (1 )
246
+ .getOutputUnit ()
247
+ .getIdentifier ();
248
+
249
+ return unit .startsWith ("fahrenhe" ) ? "fahrenheit" : "celsius" ;
250
+ }
251
+
232
252
String currentCountryCode = getCountry (reactContext );
233
253
return USES_FAHRENHEIT .contains (currentCountryCode ) ? "fahrenheit" : "celsius" ;
234
254
}
Original file line number Diff line number Diff line change @@ -1111,7 +1111,7 @@ PODS:
1111
1111
- React-jsi (= 0.73.2)
1112
1112
- React-logger (= 0.73.2)
1113
1113
- React-perflogger (= 0.73.2)
1114
- - RNLocalize (3.1 .0):
1114
+ - RNLocalize (3.2 .0):
1115
1115
- React-Core
1116
1116
- SocketRocket (0.6.1)
1117
1117
- Yoga (1.14.0)
@@ -1369,7 +1369,7 @@ SPEC CHECKSUMS:
1369
1369
React-runtimescheduler: df8945a656356ff10f58f65a70820478bfcf33ad
1370
1370
React-utils: f5bc61e7ea3325c0732ae2d755f4441940163b85
1371
1371
ReactCommon: 45b5d4f784e869c44a6f5a8fad5b114ca8f78c53
1372
- RNLocalize: e8694475db034bf601e17bd3dfa8986565e769eb
1372
+ RNLocalize: b77875884750cb6a58cd6865863fe2ba2729b72b
1373
1373
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
1374
1374
Yoga: 13c8ef87792450193e117976337b8527b49e8c03
1375
1375
Original file line number Diff line number Diff line change 6
6
"node" : " >=18"
7
7
},
8
8
"scripts" : {
9
+ "pod-install" : " cd ios && bundle install && bundle exec pod install && cd .." ,
9
10
"clean" : " rm -rf ./node_modules ./ios/Pods" ,
10
11
"install-macos" :
" yarn add [email protected] " ,
11
12
"preinstall" : " cd .. && yarn && yarn build && cd example" ,
31
32
"@types/react" : " ^18.2.47" ,
32
33
"babel-loader" : " ^9.1.3" ,
33
34
"babel-plugin-module-resolver" : " ^5.0.0" ,
34
- "pod-install" : " ^0.1.39" ,
35
35
"typescript" : " ^5.3.3" ,
36
36
"webpack" : " ^5.89.0" ,
37
37
"webpack-cli" : " ^5.1.4" ,
Original file line number Diff line number Diff line change @@ -4622,11 +4622,6 @@ pkg-up@^3.1.0:
4622
4622
dependencies :
4623
4623
find-up "^3.0.0"
4624
4624
4625
- pod-install@^0.1.39 :
4626
- version "0.1.39"
4627
- resolved "https://registry.yarnpkg.com/pod-install/-/pod-install-0.1.39.tgz#853a0585bafbd332c2ca6543854fd4919958cfb3"
4628
- integrity sha512-0kVvdLYe0CtfJEr+ISvTMxAEB0UF4JMRToPjuu9xAAq1mEqA2Ql5u7uLWX1m45BMM+7NfU4LnBbnfNjmQE9GCw==
4629
-
4630
4625
postcss-value-parser@^4.2.0 :
4631
4626
version "4.2.0"
4632
4627
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
@@ -4768,7 +4763,8 @@ react-is@^17.0.1:
4768
4763
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
4769
4764
4770
4765
" react-native-localize@link:.. " :
4771
- version "3.0.6"
4766
+ version "0.0.0"
4767
+ uid ""
4772
4768
4773
4769
4774
4770
version "0.19.10"
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ - (NSString *)getTemperatureUnitImpl {
154
154
155
155
[formatter setLocale: currentLocale];
156
156
157
- NSMeasurement *temperature = [[NSMeasurement alloc ] initWithDoubleValue: 42 .0 unit: [NSUnitTemperature celsius ]];
157
+ NSMeasurement *temperature = [[NSMeasurement alloc ] initWithDoubleValue: 1 .0 unit: [NSUnitTemperature celsius ]];
158
158
NSString *formatted = [formatter stringFromMeasurement: temperature];
159
159
NSString *unitCharacter = [formatted substringFromIndex: [formatted length ] - 1 ];
160
160
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-native-localize" ,
3
- "version" : " 3.1 .0" ,
3
+ "version" : " 3.2 .0" ,
4
4
"license" : " MIT" ,
5
5
"description" : " A toolbox for your React Native app localization." ,
6
6
"author" :
" Mathieu Acthernoene <[email protected] >" ,
You can’t perform that action at this time.
0 commit comments