6

On System Preferences, Language and Region, when I select United Kingdom the output of locale is

LANG="en_GB"
LC_COLLATE="en_GB"
LC_CTYPE="en_GB"
LC_MESSAGES="en_GB"
LC_MONETARY="en_GB"
LC_NUMERIC="en_GB"
LC_TIME="en_GB"
LC_ALL=

If I select Norway though the outputs is

LANG="en_NO"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

I suspect this is the reason why commands like ls show dates in the mon date format instead of date mon, even when Norwegian follows the latter. locale -a | grep en_NO shows nothing and I guess that's why. So I tried to copy /usr/share/locale/no_NO to /usr/share/locale/en_NO and change it to suite my needs and of course I receive mkdir: en_NO: Operation not permitted because the system volume is mounted as read only on Catalina. So, is there any way I can add my own locale?

4
  • Would putting export LC_TIME="en_GB.UTF-8" etc in your ~/.zshrc work for you?
    – lx07
    Commented Mar 15, 2020 at 12:20
  • For some reason it doesn't work, no matter what locale keeps showing me that LC_TIME is C. Also I wanted to get all the values for LC_* from defaults read NSGlobalDomain AppleLocale
    – Tae
    Commented Mar 15, 2020 at 12:54
  • 1
    You need to run source ~/.zshrc or open a new terminal emulator window after changing the file...
    – lx07
    Commented Mar 15, 2020 at 13:47
  • Yeah, I know that. Actually I don't use ZSH, I use Fish as my shell, and it's already fairly customised and everything works as expected, except this
    – Tae
    Commented Mar 15, 2020 at 17:58

2 Answers 2

3

Procedure from my cookbook to add a new locale

This works on MacOS 12.5 Monterrey over Macs with SIP (System Integrity Protection), M1 chip:

First of all check if regionality exists in the system:

locale -a | grep en_NO

If there are no results, regionality does not exist. It's no use making a copy because the root is mounted read-only and SIP doesn't allow you to modify it. Although there is the possibility of writing to it, it will not be possible to use SIP again so that the changes persist. localedef doesn't work either. The solution is to create a home folder and change the path where glibc looks for the locales:

mkdir ~/.locale
cp -rpf /usr/share/locale/en_GB.UTF-8 ~/.locale/en_NO.UTF-8
export PATH_LOCALE=~/.locale
export LC_ALL=en_NO.UTF-8

Now the system will have the corresponding regionality. The following lines could be added to the ˜/.profile file so that changes in the terminal take permanent effect:

export PATH_LOCALE=~/.locale
export LC_ALL=en_NO.UTF-8

If on the other hand locale exists on the system (if locale -a | grep en_does NOT return a result) it only achieves the following:

export LC_ALL=en_NO.UTF-8

In the same way this line can be in ˜/.profile. In my case I use es_AR based on locale provided by the system es_ES. It is the cleanest solution (and I think the correct one) that I have found so far without intervening the system.

2
  • Is /usr/local/share/locale an alternative to a user-specific installation?
    – gidds
    Commented Aug 6, 2022 at 18:52
  • @gidds Yes it is a good alternative too. While is to whole users, not for user specific. Commented Aug 7, 2022 at 2:08
0

I don't know if your issue was identical to mine, but this worked for me at least. I also noticed that my system tried to set nb_no.UTF-8 (and failed) instead of no.NO.

  1. vim ~/.config/fish/config.fish
  2. set -x LC_ALL no_NO.UTF-8
2
  • 2
    Not the same, I want en_NO, with is no available in the system, so the question is about how to add it first
    – Tae
    Commented Apr 11, 2020 at 10:20
  • This is an answer to a different question, for a fringe non-standard shell. The equivalent POSIX shell solution would be simply export LC_ALL=no_NO.UTF-8 but that won't do what you want if the OS isn't configured to actually support this locale.
    – tripleee
    Commented Jun 5 at 6:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .