locale FTP template and belchertown theme

70 views
Skip to first unread message

Juan Antonio Mosquera Casais

unread,
Nov 29, 2023, 3:03:38 AM11/29/23
to weewx-user
Hello,
I have installed the latest version of stable weewx, belchertown theme on Raspberry (raspbian). I have a problem with coding, I want to be able to generate templates like FTP with en_US coding and belchertown with es_ES coding (the Belchertown configuration allows it). But having installed in the system the two locales (en_US and es_ES) with en_US by default. When I start weewx, the first generation of the tmpl generates it correctly with en_US encoding (with dotted decimal separator) but the following generations of the file appear as es_ES. I don't understand what the problem is.
thank you

Tom Keffer

unread,
Nov 29, 2023, 11:34:47 AM11/29/23
to weewx...@googlegroups.com
Unfortunately, Version 4 allows only one locale to be set. 

Version 5 will allow a locale to be set for each report.

It's a bit of a hack, but one thing you could try is to put something like this at the top of a template (NOT TESTED):

#import locale
#locale.setlocale(locale.LC_ALL, 'es_ES')

This would set the locale. It will stay set until the next call to setlocale(). Note that this will set the locale for every time that the template is used. 

-t




--
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/594953ce-dca3-4fec-a4c1-949cbb011bd1n%40googlegroups.com.

Chuck Rhode

unread,
Nov 29, 2023, 12:16:51 PM11/29/23
to weewx...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 29 Nov 2023 08:34:17 -0800
Tom Keffer <tke...@gmail.com> wrote:

> It's a bit of a hack, but one thing you could try is to put something
> like this at the top of a template (NOT TESTED):

> #import locale
> #locale.setlocale(locale.LC_ALL, 'es_ES')

> This would set the locale. It will stay set until the next call to
> setlocale(). Note that this will set the locale for *every* time that
> the template is used.

My understanding is that the call to locale.setlocale has global
effect and impacts all running processes, but maybe I'm misinterpreting
the "not thread safe" warnings. The OP seems to want to run out of two
locales simultaneously — one for FTP and one for Belchertown. So long
as these skins are single threaded (one being complete before the other
begins), then each can call its own locale.setlocale. I'm not sure
how *weewxd* runs its "services" repertoire, though.

- --
.. Be Seeing You,
.. Chuck Rhode, Sheboygan, WI, USA
.. Weather: http://LacusVeris.com/WX
.. 31° — Wind W 13 mph

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQT+MY/5I/LMPSswTbVg2/xipKOWUgUCZWdx/AAKCRBg2/xipKOW
UqyOAJ4jbejtywEIrb6Q5Vwfb1fhVQVtQQCeKGNM4KanMdpiRvRoe1Hdpbs0xYo=
=+cD5
-----END PGP SIGNATURE-----

Juan Antonio Mosquera Casais

unread,
Nov 30, 2023, 12:53:51 AM11/30/23
to weewx-user
Thanks Tom, but it doesn't work. The strange thing is that the first generation of the template is correct (en_US) but the second and subsequent ones are again es_ES, does the Belchertown configuration somehow prevail globally?. I don't understand how the first generation is correct.
Reply all
Reply to author
Forward
0 new messages