Skip to content

Commit

Permalink
feat: can now take the device locale from android
Browse files Browse the repository at this point in the history
  • Loading branch information
wneel committed Dec 21, 2024
1 parent 04e8999 commit cfd0238
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ class GetDeviceLocaleModule(reactContext: ReactApplicationContext) :
return NAME
}

override fun getDeviceLocale(promise: Promise) {
try {
val locale = Locale.getDefault().toString()
promise.resolve(locale)
} catch (e: Exception) {
promise.reject("Error while attempting to get device locale: ", e.message)
}
}

companion object {
const val NAME = "GetDeviceLocale"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"android",
"ios",
"*.podspec",
"react-native.config.json",
"react-native.config.js",
"!ios/build",
"!**/.*"
],
Expand Down
15 changes: 15 additions & 0 deletions react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @type {import('@react-native-community/cli-types').UserDependencyConfig}
*/
module.exports = {
dependency: {
platforms: {
android: {
cmakeListsPath: 'generated/jni/CMakeLists.txt',
},
},
},
codegen: {
specsPackageName: "com.getdevicelocale",
},
};
16 changes: 16 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build:android": {
"env": ["ORG_GRADLE_PROJECT_newArchEnabled"],
"inputs": [
"package.json",
"android",
"!android/build",
"src/*.ts",
"src/*.tsx",
"example/package.json",
"example/android",
"!example/android/.gradle",
"!example/android/build",
"!example/android/app/build"
],
"outputs": []
},
"build:ios": {
"env": ["RCT_NEW_ARCH_ENABLED"],
"inputs": [
Expand Down

0 comments on commit cfd0238

Please sign in to comment.