It seems like you are trying a Linuxism on FreeBSD. On FreeBSD you should use login classes
There is a great general description of locales in What should I set my locale to and what are the implications of doing so?.
The part in that answer you can ignore is "Installing locales". FreeBSD comes with all common locales installed. You can verify this with
locale -a
But then you probably claim that you try to modify the locale and set that. And that is what I call the Linuxism. People add the locale to linux without understanding what actually happened and then set LC_ALL. The locale defines a set of LC_*
variables. LC_ALL
is then used to override those!
On FreeBSD the preferred way of changing the locale settings for a user (or system) is to use 22.2.1.1. Login Classes Method. You can change the system wide defaults here as well.
LC_ALL should only be set if you want to (forcefully) overrule any and all of the other LC_* settings. You might think you are setting a "locale" with LC_ALL
but in effect you are just setting LANG
to LANG=en_DK.UTF-8
. That is not a valid language and you should leave that to the Unicode CLDR Project. For more info on that have a look at What does “LC_ALL=C” do?
My quess is then that you do not want to invent your own new language. But from the combinations you choose my guess is that you would like the system to behave as a danish (DK) system but talk english to you. For that you can mix and match your LC_*
variables to your heats content.
Example:
LANG=en_US.UTF-8
LC_CTYPE="da_DK.UTF-8"
LC_COLLATE="da_DK.UTF-8"
LC_TIME="da_DK.UTF-8"
LC_NUMERIC="da_DK.UTF-8"
LC_MONETARY="da_DK.UTF-8"
LC_MESSAGES="en_US.UTF-8"
If you do not want to set you login class (for some reason) then you should still stick to the CLDR defined variables. That will give you the most portable results:
$ LC_ALL=C LANG=en_US.UTF-8 LC_CTYPE=da_DK.UTF-8 LC_COLLATE=da_DK.UTF-8 LC_TIME=da_DK.UTF-8 LC_NUMERIC=da_DK.UTF-8 LC_MONETARY=da_DK.UTF-8 LC_MESSAGES=en_US.UTF-8 mosh xyz.example.org
/usr/local/bin/mosh: could not get canonical name for xyz.example.org: hostname nor servname provided, or not known
ssh_exchange_identification: Connection closed by remote host
/usr/local/bin/mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).
$
If it is a locale setup you want to use commonly then you can set it up using a login class. Either see the FreeBSD Handbook or my answer to SSH to FreeBSD in UTF-8
I think your answer lies somewhere above. But if we take you question verbatim then
FreeBSD current will add a UTF-8 C locale in 13.0 (see commit r340144). If you really truly want to see how to add a new locale then have a look at introduce C.UTF-8 locale
UPDATE
The directory /usr/share/locale/*
is just a directory. If you make a verbatim copy as in the Q - things will work on FreeBSD 11.2. I still recommend using a verbose LC_ALL
or login classes. For now I think the problem has been "fat fingers".
The directory contains symlinks and definition files. The files can be created by localdef which replaced mklocale in 2015.
If you do not want to change the actual collation order then you can link to a language which have the "proper" collation order - or simply copy the file. PATH_LOCALE=/usr/share/locale
is implicit as it is the default.
I made a verbatim copy on my system to test
and en_DK.UTF-8
. They show up with locale -a
immediately. Both worked as expected:
$ locale -a | grep -e en_DK -e test
en_DK.UTF-8
test
$ LC_ALL=test mosh xyz.example.org
/usr/local/bin/mosh: could not get canonical name for xyz.example.org: hostname nor servname provided, or not known
ssh_exchange_identification: Connection closed by remote host
/usr/local/bin/mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).
$ LC_ALL=test /bin/sh
$ locale
LANG=
LC_CTYPE="test"
LC_COLLATE="test"
LC_TIME="test"
LC_NUMERIC="test"
LC_MONETARY="test"
LC_MESSAGES="test"
LC_ALL=test
$ exit
$ LC_ALL=en_DK.UTF-8 mosh xyz.example.org
/usr/local/bin/mosh: could not get canonical name for xyz.example.org: hostname nor servname provided, or not known
ssh_exchange_identification: Connection closed by remote host
/usr/local/bin/mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).
$ LC_ALL=dummy mosh xyz.example.org
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = "dummy",
LANG = (unset)
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = "dummy",
LANG = (unset)
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
/usr/local/bin/mosh: could not get canonical name for xyz.example.org: hostname nor servname provided, or not known
ssh_exchange_identification: Connection closed by remote host
/usr/local/bin/mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).
$ uname -a
FreeBSD test 11.2-RELEASE FreeBSD 11.2-RELEASE #0 r335510: Fri Jun 22 04:32:14 UTC 2018 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64