Formatting numbers with internationalized skins

126 views
Skip to first unread message

michael.k...@gmx.at

unread,
May 3, 2023, 11:07:46 AM5/3/23
to weewx-user
I need a hint how to handle formatting numbers (values) with internationalized skins. Specifying the language doesn't have an apparent effect on how values are formatted, it seems like number value formatting is connected to the systems (default?) locale. I even notice inconsistent results, for instance with the standard skin: temperature is formatted in another way than an alamnac value: in the specific case the temperature value is formatted with a comma as decimal separator, the almanac angle with a period as decimal separator.

Is there a way to specifiy a locale to be used for a skin (or a translated skin)? 2023-05-03 17_01_24.png

p q

unread,
May 3, 2023, 11:18:09 AM5/3/23
to weewx...@googlegroups.com
In my professional life I ask my devs to get the locale from the browser and use the tech stack to do the conversion automatically. Like JavaScript  .toLocaleString(). 

Don't know if that's feasible here. 

On Wed, May 3, 2023, 8:07 AM michael.k...@gmx.at <michael.k...@gmx.at> wrote:
I need a hint how to handle formatting numbers (values) with internationalized skins. Specifying the language doesn't have an apparent effect on how values are formatted, it seems like number value formatting is connected to the systems (default?) locale. I even notice inconsistent results, for instance with the standard skin: temperature is formatted in another way than an alamnac value: in the specific case the temperature value is formatted with a comma as decimal separator, the almanac angle with a period as decimal separator.

Is there a way to specifiy a locale to be used for a skin (or a translated skin)? 2023-05-03 17_01_24.png

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/62429245-50ef-4f87-89ac-b8cb1b0d064en%40googlegroups.com.

michael.k...@gmx.at

unread,
May 3, 2023, 12:59:35 PM5/3/23
to weewx-user
Doesn't apply here since the browser gets static HTML, produced by weewx on a (potentially) remote machine different from the webserver, the HTML is downloaded from. I am looking for a way to tell weewx to format number values for an internationalized skin in a certain way. As far as I know, only the language can be set for an internationalized skin, not the locale.

p q

unread,
May 3, 2023, 1:41:53 PM5/3/23
to weewx...@googlegroups.com
Are you sure? I use javascript on my weewx pages - do to simple things like rotate through a set of photos. I also use the steelseries gauges that are all javascript running in the browser. Is there a reason you can't embed javascript to grab the locale from the browser and do the formatting?



--
Peter Quinn
(415)794-2264

michael.k...@gmx.at

unread,
May 4, 2023, 3:26:22 AM5/4/23
to weewx-user
Yes, in the particular case (the Standard skin mentioned above) I am sure. There is a script, but it is dealing with NOAA data files. The same thing seems to occur with the Seasons skin as well. And with the skin I maintain. The OS locale seems to have an effect on how number values are formatted, which results in mixed presentation of number values under certain circumstances. 

Tom Keffer

unread,
May 4, 2023, 9:37:22 AM5/4/23
to weewx...@googlegroups.com
I can confirm that some of the almanac values (right ascension, declination, among others) are returned as simple numbers, not ValueHelpers, so they are not subject to locale formatting. That's a bug.

I should be able to fix it for V5.

michael.k...@gmx.at

unread,
May 4, 2023, 10:07:35 AM5/4/23
to weewx-user
Thanks Tom. On which setting does the locale formatting depend? Is it the OS default locale? In other words: even with internationalized skins numbers are formatted in a single way, regardless of the language? Since only the language is configured to translate skins, I assume so. My research so far showed it's not so straight forward to work with different locales at the same time in python, without using Babel or something similar.

Tom Keffer

unread,
May 4, 2023, 3:36:12 PM5/4/23
to weewx...@googlegroups.com
The decimal and thousands separators are both set by the OS's locale. 

-tk

michael.k...@gmx.at

unread,
May 5, 2023, 4:51:57 AM5/5/23
to weewx-user
Have you ever considered making it possible to set the locale (instead, or optional) for skin internationalization? So with internationalized skins, you get a localized, not only translated presentation?

Tom Keffer

unread,
May 5, 2023, 7:50:17 AM5/5/23
to weewx...@googlegroups.com
It's a reasonable suggestion. I'll look into it.

Issue #867 to track.

Reply all
Reply to author
Forward
0 new messages