Skip to content

Instantly share code, notes, and snippets.

@devnoname120
Last active March 14, 2024 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devnoname120/9edbb503a67add7fd9b8f881e93942c0 to your computer and use it in GitHub Desktop.
Save devnoname120/9edbb503a67add7fd9b8f881e93942c0 to your computer and use it in GitHub Desktop.
XPrivacyLua Pro — Override system locale/language — java.util.Location.getDefault()
{
"script": [
{
"name": "Privacy.Locale.getDefault",
"code": "function after(hook, param)\n local myLocale = luajava.newInstance(\"java.util.Locale\", \"fr\", \"FR\")\n\tparam:setResult(myLocale)\n\treturn true\nend"
}
],
"definition": [
{
"builtin": false,
"collection": "Privacy",
"group": "Get.Locale",
"name": "Locale.getDefault",
"author": "devnoname120",
"version": 1,
"description": "Overrides the system locale for a specific app",
"className": "java.util.Locale",
"methodName": "getDefault",
"parameterTypes": [],
"returnType": "java.util.Locale",
"minSdk": 1,
"maxSdk": 99,
"minApk": 0,
"maxApk": 2147483647,
"enabled": true,
"optional": false,
"usage": true,
"notify": false,
"luaScript": "@Privacy.Locale.getDefault"
}
]
}
@devnoname120
Copy link
Author

I couldn't find this on the internet so I built a hook for changing the system locale / language of specific apps. I'm overriding java.util.Locale.getDefault() for that purpose.

I hardcoded French (France) inside but you can easily change it, and even make it appear in the XPrivacyLua Pro settings.

It only hooks one method because the app that I needed to target (SNCF Connect) doesn't use the other java.util.Locale methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment