Hey there,
I’m new to HaxeUI and try to prototype some of my work-project frontends with it (html5 backend). Really like it so far!
One problem I have is the documentation of certain features. There are some (empty) guides (Guides - HaxeUI API Docs) and of course much looking into examples. Or am I missing something?
The main question I have is about locale settings and especially date formats. I’m using the dropdown component as date picker and the date format is “03/10/2023”. I need the german format “03.10.2023” to display. I managed it with Formats.dateFormatShort = "%d.%m.%Y"; after diving into the source code.
Is there a place where this is documented (or I could do a pull request to document that)?
Is this the intended way of doing it?
Thanks in advance and thanks for this amazing library!
Max
One problem I have is the documentation of certain features.
Docs are certainly the weakest point, apart from the unfinished guides there are certain things (like the locale system) that isnt even started
The main question I have is about locale settings and especially date formats. I’m using the dropdown component as date picker and the date format is “03/10/2023”. I need the german format “03.10.2023” to display. I managed it with Formats.dateFormatShort = "%d.%m.%Y"; after diving into the source code.
Now I understand! I wasn’t aware that this is the default format. Living in germany for decades and after googling a bit I can tell you that %d.%m.%Y is the common way of writing dates (also see The Date in German).
I don’t know if it’s a good idea to change the defaults because applications may depend on that?
So someone just can write LocaleManager.instance.language = "de"; to set the correct format, am I right?
If I find time I’ll try to document that (and some other things) in the guides via PR.
PlatformBase.getSystemLocale() returns (in html5) the browser setting ("de" in my case) but is never utilized (not familiar with the codebase but could not find it) in core or html5
There’s also the <html lang="de"> attribute which could be utilized (but not is I guess)
And like said before the LocaleManager.instance.language
Are these settings independent from each other or do they play together somehow?
IMHO the LocaleManager.instance.language should take PlatformBase.getSystemLocale() (or "en" as default) but can be overridden by the <html lang="de"> attribute. Then it’s a solid default that can be overridden when needed for custom localization (as showed here Component Explorer - HaxeUI).
Sorry for giving my opinion but not being so safe about the source code, that are just my thoughts on this topic. Currently browsing the code for more insights
I think it should automatically lookup the locale (if it can)… at least im sure there is code to do that, maybe its not utilized by default - just checking the code myself - its been a while since i looked at the locale stuff too
Im just wondering if this should happen by default… it probably should i guess, just worried about changing peoples apps without them understanding why - i guess I could also add a flag to stop this behaviour
Alright, after some reflection, i think the system should detect the system locale as best it can. Otherwise, its relatively pointless, the idea of haxeui in general is that things should “just work” and you shouldnt need to manually set the locale each time in each app, so to that end:
LocaleManager will automatically try to set the local, for this to happen:
LocaleManager.instance.autoSetLocale has to be true (the default)
You havent previously manually set the locale (like from settings or something)
the detected locale isnt null
the detected local exists in haxeui
-D haxeui-dont-detect-locale doesnt exist as a compiler flag
I think its better this way, its easy to turn off and it just makes more sense to have the locale system kick in by default.
Cheers,
Ian
PS: ive also included your checking of the lang html attribute in haxeui-html5, as that also makes sense, means you can have the browser in one language and the page in another and the page takes precedence.