Android Question Dynamically change locale for DateTime

JackKirk

Well-Known Member
Licensed User
Longtime User
In this post:

https://www.b4x.com/android/forum/threads/b4xdatetemplate-change-of-month-weekday.120348/post-754070

Erel shows how to override the device locale so the host app can use a different locale for DateTime functions.

I can only get it to work if I put the code snippet in the app's starter service - which is what Erel is saying.

I am developing an app that supports all languages supported by AWS Translate:

https://docs.aws.amazon.com/translate/latest/dg/what-is.html

The app gets the device's locale and uses this to translate English phrases to the device language.

The app can also toggle to English then back to the device language.

Only problem is when toggling from the device language to English all DateTime functions stay in the device language.

I'm trying to find a way to dynamically change the locale as per Erel's post - I've scoured the forums without success.

Any and all suggestions appreciated...
 

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel,

I looked at that closely but there are a couple of reasons why it is not a good fit:

1. My B4A app is big - I would be making extensive changes.
2. It has a sister B4i app that has roughly 90% parallel code - if I make the changes in the B4A app then there would be a much reduced "parallelity" - which is not good for long term maintenance.
3. The B4A app uses wheelpicker:
which seems to use the device locale - which from what I can see won't be helped by AHlocale which is running in a "parallel universe" to the device locale.

Any other suggestions?
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Thanks Erel, with a bit of fiddling for my circumstances I got it working - works for wheelpicker too!
 
Upvote 0
Top