Skip to content

Commit f453f4d

Browse files
committed
feat: device language from react-native
1 parent c1cdfa5 commit f453f4d

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import { numberFormat } from "@freakycoder/react-native-helpers";
121121
| vw | number | get the device's width but as a **viewport unit** |
122122
| vmin | number | get the device's screen width/height as a **viewport unit** which are **minimum** depend on the landscape or portrait mode |
123123
| vmax | number | get the device's screen width/height as a **viewport unit** which are **maximum** depend on the landscape or portrait mode |
124+
| deviceLanguage | string | get the device's language (en_US) |
124125
125126
## DeviceInfo Props
126127

lib/helpers/device/DeviceInfo.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { Platform, Dimensions } from "react-native";
1+
import { Platform, Dimensions, NativeModules } from "react-native";
2+
3+
// i.e: en_US
4+
const deviceLanguage =
5+
Platform.OS === "ios"
6+
? NativeModules.SettingsManager.settings.AppleLocale ||
7+
NativeModules.SettingsManager.settings.AppleLanguages[0] //iOS 13
8+
: NativeModules.I18nManager.localeIdentifier;
9+
210
// ? Screen Constants
311
const Screen = Dimensions.get("screen");
412
const ScreenWidth: number = Screen.width;
@@ -49,4 +57,5 @@ export {
4957
WindowScale,
5058
WindowFontScale,
5159
PlatformVersion,
60+
deviceLanguage,
5261
};

lib/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
WindowScale,
1717
WindowFontScale,
1818
PlatformVersion,
19+
deviceLanguage,
1920
} from "./helpers/device/DeviceInfo";
2021

2122
import {
@@ -46,6 +47,7 @@ export {
4647
WindowScale,
4748
WindowFontScale,
4849
PlatformVersion,
50+
deviceLanguage,
4951
getStatusBarHeight,
5052
hasNotch,
5153
hasNotchOnly,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@freakycoder/react-native-helpers",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "All helpers in one; iPhone series support, dimensions helper, hasNotch helper, normalize text helper and text helpers for React Native with very easy use",
55
"keywords": [
66
"ios",

0 commit comments

Comments
 (0)