Skip to content

Date strings not always in locale #256

@BertLindeman

Description

@BertLindeman

The localized date and times are not always translated,
see in issue 185

I think I found a reason.
In the forcast squares before the day.setText calls I added a setlocale and some prints.

Before and after the setlocale it shows:

BEFORE: in wxfinished_tm3 ('en_US', 'UTF-8') default: ('en_US', 'UTF-8')
AFTER   in wxfinished_tm3: ('nl_NL', 'UTF-8') default: ('en_US', 'UTF-8')

So each time e.g. wxfinished_tm3 is called the locale is again back to the default.

The setlocale is done in the function Tick.
I assume the function tick() runs as a separate thread (or something like it)
Could that be the reason that sometimes I saw the correct locale datea and most of the time not.

I copied the setting of the locale near line 2200 between:

width = rec.width()

signal.signal(signal.SIGINT, myquit)

I added there:

# ================== Set locale here to test if the dates/times ARE in the locales:

if Config.DateLocale != "":
    try:
        locale.setlocale(locale.LC_TIME, Config.DateLocale)
    except Exception as e:
        print("In Tick setlocale failed:", e, "\n\t", Config.DateLocale)
        raise SystemExit(1)

Could this be the cause?

In python3 I did not see a similar problem, but that can be a timing issue aswell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions