You are not logged in.

#1 2017-08-03 08:58:41

7thSon
Member
Registered: 2017-05-07
Posts: 186

[SOLVED] Date format not updating with locale change?

I want to have english text but swedish date formats and other values, so I have my locale set up as sv_SE with locale-gen, and in ~/.bashrc I have:

export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="sv_SE.UTF-8"
export LC_TIME="en_DK.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_MONETARY="sv_SE.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_PAPER="sv_SE.UTF-8"
export LC_NAME="en_US.UTF-8"
export LC_ADDRESS="en_US.UTF-8"
export LC_TELEPHONE="sv_SE.UTF-8"
export LC_MEASUREMENT="sv_SE.UTF-8"
export LC_IDENTIFICATION="en_US.UTF-8"

in terminal I get this output when running "locale" command:

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=sv_SE.UTF-8
LC_TIME=sv_SE.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=sv_SE.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=sv_SE.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=sv_SE.UTF-8
LC_MEASUREMENT=sv_SE.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

However the date format is "MM/DD/YY HH:mm", which is definitely not sv_SE locale.
I also tried changing the LC_TIME to en_DK according to some suggestions in other forums, but still the same.

So why would my date format in thunderbird and pcmanfm (and probably other software as well) show the wrong date format locale?

Last edited by 7thSon (2017-08-05 10:02:42)

Offline

#2 2017-08-03 09:00:53

dockland
Member
From: Sweden
Registered: 2015-06-06
Posts: 861

Re: [SOLVED] Date format not updating with locale change?

I have swedish formats and english text. I'll give you a notification when back home. Don't remember the exact config, but it was fairly easy. (Perhaps you will get help before i get home, but just in case)


I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.
I use it to look at funny pictures of cats and to argue with strangers.

Offline

#3 2017-08-03 09:17:07

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,405
Website

Re: [SOLVED] Date format not updating with locale change?

Did you edit /etc/locale.gen and run locale-gen?

https://wiki.archlinux.org/index.php/Locale


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#4 2017-08-03 10:03:41

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Date format not updating with locale change?

WorMzy wrote:

Did you edit /etc/locale.gen and run locale-gen?

https://wiki.archlinux.org/index.php/Locale

Yes, it was en_US before, I changed it to sv_SE, but no change.

Offline

#5 2017-08-03 10:33:03

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,405
Website

Re: [SOLVED] Date format not updating with locale change?

As a sanity check, could you run

localectl list-locales

Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#6 2017-08-03 16:30:49

dockland
Member
From: Sweden
Registered: 2015-06-06
Posts: 861

Re: [SOLVED] Date format not updating with locale change?

Mine:

[arch@dome ~]$ locale -a
C
en_US.utf8
POSIX
sv_SE.utf8
[arch@dome ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=sv_SE.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=sv_SE.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=sv_SE.UTF-8
LC_MEASUREMENT=sv_SE.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=
[arch@dome ~]$ localectl list-locales
en_US.utf8
sv_SE.utf8

I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.
I use it to look at funny pictures of cats and to argue with strangers.

Offline

#7 2017-08-03 17:59:40

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,694

Re: [SOLVED] Date format not updating with locale change?

7thSon wrote:
WorMzy wrote:

Did you edit /etc/locale.gen and run locale-gen?

https://wiki.archlinux.org/index.php/Locale

Yes, it was en_US before, I changed it to sv_SE, but no change.

Changed it to? You need to have all of the ones you want uncommented. If you're just switching back and forth with only one uncommented, it won't work.

Offline

#8 2017-08-03 22:44:36

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Date format not updating with locale change?

Scimmia wrote:
7thSon wrote:
WorMzy wrote:

Did you edit /etc/locale.gen and run locale-gen?

https://wiki.archlinux.org/index.php/Locale

Yes, it was en_US before, I changed it to sv_SE, but no change.

Changed it to? You need to have all of the ones you want uncommented. If you're just switching back and forth with only one uncommented, it won't work.

That was indeed an error on my part, I uncommented both sv_SE, en_US and en_DK now and rebooted, but the date format is still wrong.
Output

[user@arch ~]$ locale -a
C
en_DK.utf8
en_US.utf8
POSIX
sv_SE.utf8
[user@arch ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=sv_SE.UTF-8
LC_TIME=en_DK.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=sv_SE.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=sv_SE.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=sv_SE.UTF-8
LC_MEASUREMENT=sv_SE.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=
[user@arch ~]$ localectl list-locales
en_DK.utf8
en_US.utf8
sv_SE.utf8

Offline

#9 2017-08-04 05:23:56

dockland
Member
From: Sweden
Registered: 2015-06-06
Posts: 861

Re: [SOLVED] Date format not updating with locale change?

After you uncomment a line in /etc/locale.gen you have to run locale-gen again. Didn't see you stating that. Reboot wont help.


I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.
I use it to look at funny pictures of cats and to argue with strangers.

Offline

#10 2017-08-04 06:57:18

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,268

Re: [SOLVED] Date format not updating with locale change?

It's in "locale -a", though.

Question: how *exactly* do you determine the time format?
Because as for thunderbird: while I don't use it but am gonna bet that mozilla simply ignores your locale settings in favor of an own config key.
Pcmanfm however reacts to the locale setting and has YYYY-MM-DD for sv_SE.UTF-8 and en_DK.UTF-8 as LC_TIME

Compare

date +%x
LC_TIME=sv_SE.UTF-8 date +%x
LC_TIME=en_DK.UTF-8 date +%x
LC_TIME=en_US.UTF-8 date +%x

Online

#11 2017-08-04 11:13:14

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Date format not updating with locale change?

dockland wrote:

After you uncomment a line in /etc/locale.gen you have to run locale-gen again. Didn't see you stating that. Reboot wont help.

Yes I actually did do locale-gen after the changes, just forgot to mention it.

seth wrote:

It's in "locale -a", though.

Question: how *exactly* do you determine the time format?
Because as for thunderbird: while I don't use it but am gonna bet that mozilla simply ignores your locale settings in favor of an own config key.
Pcmanfm however reacts to the locale setting and has YYYY-MM-DD for sv_SE.UTF-8 and en_DK.UTF-8 as LC_TIME

Compare

date +%x
LC_TIME=sv_SE.UTF-8 date +%x
LC_TIME=en_DK.UTF-8 date +%x
LC_TIME=en_US.UTF-8 date +%x

I don't really understand your question on how I determine the time format, but what I want is the output of LC_TIME=sv_SE.UTF-8 date +%x.
In my terminal however, just doing date +%x actually shows the swedish format YYYY-MM-DD, so the question then I guess is why doesn't pcmanfm?
I don't know if thunderbird uses its own format, but at least pcmanfm should show the correct format if it uses the system locale as you say.

EDIT:
I just tried running "LC_TIME=sv_SE.UTF-8 thunderbird" and that manages to run thunderbird with the correct swedish date format, however if I do the same with pcmanfm, it still shows the wrong format.

Last edited by 7thSon (2017-08-04 11:23:21)

Offline

#12 2017-08-04 11:24:13

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] Date format not updating with locale change?

7thSon wrote:

In my terminal however, just doing date +%x actually shows the swedish format YYYY-MM-DD, so the question then I guess is why doesn't pcmanfm?

I'm guessing because you don't start pcmanfm from an interactive bash session. You never said/showed anything about actually setting the locale, except for exporting those variables in ~/.bashrc.

https://wiki.archlinux.org/index.php/Lo … the_locale

Offline

#13 2017-08-04 11:55:03

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Date format not updating with locale change?

Raynman wrote:

I'm guessing because you don't start pcmanfm from an interactive bash session. You never said/showed anything about actually setting the locale, except for exporting those variables in ~/.bashrc.

https://wiki.archlinux.org/index.php/Lo … the_locale

I think you're right, if I just run "pcmanfm" in a terminal, the date format is correct, same if I run "thunderbird" in terminal.
However if I understand correctly my locale is actually set, the ouput from "locale" in terminal is:.

[user@arch ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=sv_SE.UTF-8
LC_TIME=sv_SE.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=sv_SE.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=sv_SE.UTF-8
LC_MEASUREMENT=sv_SE.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

And I also put all those above lines into /etc/locale.conf to set the system locale. Am I still missing something?

Last edited by 7thSon (2017-08-04 11:56:13)

Offline

#14 2017-08-04 12:36:49

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,268

Re: [SOLVED] Date format not updating with locale change?

Save this as "env_of" or so, make it executable and run "env_of pcmanfm | grep LC" with a "broken" pcmanfm up.

Also provide the output of "localectl" and explain how you usually run pcmanfm, what kind of desktop session this is, how you log in etcetc.

#!/bin/sh
if [[ $1 =~ "^[0-9]+$" ]]; then
    tr '\0' '\n' < /proc/$1/environ
else
    for PID in `pidof $1`; do
        echo -e "$PID ( $(</proc/$PID/cmdline) )\n====================================="
        tr '\0' '\n' < /proc/$PID/environ
        echo -e "===================================================\n"
    done
fi

Online

#15 2017-08-05 09:25:37

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Date format not updating with locale change?

seth wrote:

Save this as "env_of" or so, make it executable and run "env_of pcmanfm | grep LC" with a "broken" pcmanfm up.

Also provide the output of "localectl" and explain how you usually run pcmanfm, what kind of desktop session this is, how you log in etcetc.

#!/bin/sh
if [[ $1 =~ "^[0-9]+$" ]]; then
    tr '\0' '\n' < /proc/$1/environ
else
    for PID in `pidof $1`; do
        echo -e "$PID ( $(</proc/$PID/cmdline) )\n====================================="
        tr '\0' '\n' < /proc/$PID/environ
        echo -e "===================================================\n"
    done
fi

Here is the output from env_of:

[user@arch .scripts]$ sh env_of.sh pcmanfm | grep LC
env_of.sh: line 6: warning: command substitution: ignored null byte in input
LC_MEASUREMENT=en_GB.UTF-8
LC_PAPER=sv_SE.UTF-8
LC_MONETARY=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_NUMERIC=sv_SE.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_TELEPHONE=sv_SE.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_TIME=en_GB.UTF-8

Output of localectl:

   System Locale: LANG=en_US.UTF-8
                  LC_NUMERIC=sv_SE.UTF-8
                  LC_TIME=sv_SE.UTF-8
                  LC_PAPER=sv_SE.UTF-8
                  LC_TELEPHONE=sv_SE.UTF-8
                  LC_MEASUREMENT=sv_SE.UTF-8
       VC Keymap: sv-latin1
      X11 Layout: se

My desktop session is XFCE, I have autologin set up via ~/.bash_profile which runs "startxfce4".
Usually I run pcmanfm with a keyboard shortcut which launches /usr/bin/pcmanfm (this is set via XFCE keyboard shortcuts).

...And I just found that in ~/.bash_profile there were two lines; "export LC_TIME=en_GB.UTF-8" and "export LC_MEASUREMENT=en_GB.UTF-8"...
Will try removing these, since they have to be the source of the en_GB ouput from your script.

...And it works! So ~/.bash_profile was the culprit since it seems to apply its lines after .bashrc.
Just a small follow up question; I see that the calendar is now also set correctly with monday as the first day of the week, but the day names are in swedish, can this be changed?
EDIT: Yes, I fixed it by copying the day and month names from en_US into sv_SE and running locale-gen.

Thanks for the help, will mark this solved!

Last edited by 7thSon (2017-08-05 10:02:28)

Offline

#16 2017-08-05 10:51:15

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,268

Re: [SOLVED] Date format not updating with locale change?

What's the purpose of "LC_TIME=sv_SE.UTF-8"? If it's only about getting "2017-08-05" instead of "08/05/2017", en_DK should do that and provide you English names rather than Swedish (or Danish) ones (w/o messing around with the locale files)

Online

#17 2017-08-06 08:54:50

7thSon
Member
Registered: 2017-05-07
Posts: 186

Re: [SOLVED] Date format not updating with locale change?

seth wrote:

What's the purpose of "LC_TIME=sv_SE.UTF-8"? If it's only about getting "2017-08-05" instead of "08/05/2017", en_DK should do that and provide you English names rather than Swedish (or Danish) ones (w/o messing around with the locale files)

You're right, en_DK probably would have done the same thing, I just didn't think of that at the time.

Offline

Board footer

Powered by FluxBB