Invalid locale

I get this strange message (strange to me) every now and then. I've browsed the net and also read the handbook ( https://docs.freebsd.org/en/books/handbook/l10n/ ) but I must have made something wrong in the previous installation of my FreeBSD. I've followed the instructions to the best of my abilities but I cannot get it to work.

I suspect there is something fishy with my settings (I'm sure I'm to blame since I guess I played around with stuff I shouldn't have)

When I try to execute "top" for instance I get

Code:
$ top
invalid locale.

If I run the command "locale" I get the output:

Code:
$ locale
LANG=sv
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=

I can do the command

Code:
LANG=C

And then top works great. But next reboot it comes back again... what overrides the LANG command?

Secondly

I'm unable to use my keyboard to its full extent, for instance the swedish letters å ä ö and also special characters like "~" is not possible in any terminal-editor. Its a bit annoying. I can use it in my webbrowser like chromium but not in any terminal editor

When I enter ".login_conf" it reads:

Code:
me:\
        :charset=iso-8859-1:\
        :lang=sv_SE.ISO8859-1:
        :tc=default:

Any ideas?
 
In /etc/rc.conf, do you have keymap="se.kbd"?
This is what I have in /etc/rc.conf

Code:
clear_tmp_enable="YES"
hostname="FreeBSD-dell"
keymap="swedish.iso"
font8x8="iso15-8x8"
font8x14="iso15-8x14"
font8x16="iso15-8x16"
#keymap="se.kbd"
wlans_iwm0="wlan0"
ifconfig_wlan0="WPA DHCP"
ifconfig_wlan0_ipv6="inet6 accept_rtadv"
create_args_wlan0="country SE regdomain FCC4"
sshd_enable="YES"
moused_nondefault_enable="NO"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
dbus_enable="YES"
moused_enable="YES"
hald_enable="YES"

kld_list="i915kms"
lightdm_enable="YES"
sddm_enable="YES"
seatd_enable="YES"
 
Why did you change keymap to swedish.iso? I fear that this file isn't a keymap file.
The right value for keymap is se.kbd.
 
Why did you change keymap to swedish.iso? I fear that this file isn't a keymap file.
The right value for keymap is se.kbd.

I will not be able to answer that. I've been running for like 5 days and the information overload has been massive. I'm sure I've followed a guide but maybe missunderstood.

I have changed to se.kbd according to your info.

However the problem is still there.
 
This isn't a valid locale. See available locales in /usr/share/locale. You probably want either sv_SE.UTF-8 or sv_FI.UTF-8.
Thanks.

But if I write

LANG="sv_SE.UTF-8"

It still doesn't work. Do I need to run cap_mkdb on some file in order to have it work? Anyway, when I login again afterwards its still the same. Something is overwriting the LANG=sv
 
zoor@FreeBSD-dell:/etc $ LANG="sv_SE.UTF-8"
zoor@FreeBSD-dell:/etc $ locale
LANG=sv_SE.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=en_US.UTF-8
zoor@FreeBSD-dell:/etc $ cap_mkdb
usage: cap_mkdb [-b | -l] [-v] [-f outfile] file ...
zoor@FreeBSD-dell:/etc $ cap_mkdb locale
cap_mkdb: locale.db: Permission denied
zoor@FreeBSD-dell:/etc $ sudo cap_mkdb locale
Lösenord:
cap_mkdb: file argument: No such file or directory
zoor@FreeBSD-dell:/etc $

What am I doing wrong?
 
Ok this was the output:

zoor@FreeBSD-dell:~ $ locale
LANG=sv
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
zoor@FreeBSD-dell:~ $ LANG="sv_SE.UTF-8"
zoor@FreeBSD-dell:~ $ locale
LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_ALL=
zoor@FreeBSD-dell:~ $ sudo cap_mkdb .login_conf
Lösenord:
zoor@FreeBSD-dell:~ $ sudo cap_mkdb /etc/login.conf
zoor@FreeBSD-dell:~ $ locale
LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_ALL=
zoor@FreeBSD-dell:~ $
So far so good... it still doesn't get me to use "~" or å ä ö in the terminal. I can however run "top" with no "invalid locale" message.

I logout... enter again. And this is the output:

zoor@FreeBSD-dell:~ $ locale
LANG=sv
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=

So something is overwriting the added settings upon login.
 
I logout... enter again. And this is the output:
Just using zoor@FreeBSD-dell:~ $ LANG="sv_SE.UTF-8" doesn't survive a logout-login sequence.
In your command sequence I don't see any changes made as bsduck suggested:
- make the changes to ~/.login_conf
- do cap_mkdb ~/.login_conf
- relogin

After logging in again, you should have:
Code:
 % locale
LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_ALL=
% echo $MM_CHARSET
UTF-8
 
In your command sequence I don't see any changes made as bsduck suggested:
- make the changes to ~/.login_conf
- do cap_mkdb ~/.login_conf
- relogin

After logging in again, you should have:
Code:
 % locale
LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_ALL=
% echo $MM_CHARSET
UTF-8
Ok here it goes...

~/login_conf looks like this:

#
# see login.conf(5)
#

me:\
:charset=UTF-8:\
:lang=sv_SE.UTF-8:

run the cap_mkdb command
zoor@FreeBSD-dell:~ $ cap_mkdb .login_conf
and then logout

upon login in I check the locale:

zoor@FreeBSD-dell:~ $ locale
LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_ALL=
zoor@FreeBSD-dell:~ $

Back to square one... how can this be?
 
Do you have any locale settings in ~/.profile or ~/.shrc ?
In ~/profile it reads:

#
# .profile - Bourne Shell startup script for login shells
#
# see also sh(1), environ(7).
#

# These are normally set through /etc/login.conf. You may override them here
# if wanted.
# PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin; export PATH

# Setting TERM is normally done through /etc/ttys. Do only override
# if you're sure that you'll never log in via telnet or xterm or a
# serial line.
# TERM=xterm; export TERM

EDITOR=nano; export EDITOR
PAGER=less; export PAGER

# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV

# Let sh(1) know it's at home, despite /home being a symlink.
if [ "$PWD" != "$HOME" ] && [ "$PWD" -ef "$HOME" ] ; then cd ; fi

# Query terminal size; useful for serial lines.
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi

# Display a random cookie on each login.
if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune freebsd-tips ; fi
and in ~/.shrc it reads

# .shrc - bourne shell startup file
#
# This file will be used if the shell is invoked for interactive use and
# the environment variable ENV is set to this file.
#
# see also sh(1), environ(7).
#


# file permissions: rwxr-xr-x
#
# umask 022

# Uncomment this to enable the builtin vi(1) command line editor in sh(1),
# e.g. ESC to go into visual mode.
# set -o vi


# some useful aliases
alias h='fc -l'
alias j=jobs
alias m="$PAGER"
alias ll='ls -laFo'
alias l='ls -l'
alias g='egrep -i'

# # be paranoid
# alias cp='cp -ip'
# alias mv='mv -i'
# alias rm='rm -i'

# # csh like history on arrow up and down
bind ^[[A ed-search-prev-history
bind ^[[B ed-search-next-history

# # ctrl+arrow allow to jump from words to words
bind "\\e[1;5C" em-next-word
bind "\\e[1;5D" ed-prev-word
alias history='fc -l'

# Fix home/del for mobaxterm
bind ^[[5~ ed-move-to-beg
bind ^[[6~ ed-move-to-end

# set prompt: ``username@hostname:directory $ ''
PS1="\u@\h:\w \\$ "

# search path for cd(1)
# CDPATH=:$HOME

So I dont think so... ? But maybe it should be?
 
No, that's fine as is, there could have been something conflicting with your settings there, but there clearly isn't and you don't need to add anything.

Your locale now seems to be properly configured, but it's weird that you still get ISO8859-1 as charset. What do you have in /etc/login.conf ?

Can you type Swedish letters on the command line now?
 
The problem is that everythime I logout (and restart the computer) the settings in locale goes back to this:

zoor@FreeBSD-dell:~ $ locale
LANG=sv
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
my /etc/login.conf looks like this:

zoor@FreeBSD-dell:~ $ cat /etc/login.conf
# login.conf - login class capabilities database.
#
# Remember to rebuild the database after each change to this file:
#
# cap_mkdb /etc/login.conf
#
# This file controls resource limits, accounting limits and
# default user environment settings.
#
#

# Default settings effectively disable resource limits, see the
# examples below for a starting point to enable them.

# defaults
# These settings are used by login(1) by default for classless users
# Note that entries like "cputime" set both "cputime-cur" and "cputime-max"
#
# Note that since a colon ':' is used to separate capability entries,
# a \c escape sequence must be used to embed a literal colon in the
# value or name of a capability (see the ``CGETNUM AND CGETSTR SYNTAX
# AND SEMANTICS'' section of getcap(3) for more escape sequences).

default:\
:passwd_format=sha512:\
:copyright=/etc/COPYRIGHT:\
:welcome=/var/run/motd:\
:setenv=BLOCKSIZE=K:\
:mail=/var/mail/$:\
:path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\
:nologin=/var/run/nologin:\
:cputime=unlimited:\
:datasize=unlimited:\
:stacksize=unlimited:\
:memorylocked=64K:\
:memoryuse=unlimited:\
:filesize=unlimited:\
:coredumpsize=unlimited:\
:openfiles=unlimited:\
:maxproc=unlimited:\
:sbsize=unlimited:\
:vmemoryuse=unlimited:\
:swapuse=unlimited:\
:pseudoterminals=unlimited:\
:kqueues=unlimited:\
:umtxp=unlimited:\
:pipebuf=unlimited:\
:priority=0:\
:ignoretime@:\
:umask=022:\
#:charset=ISO8859-1:\
#:LANG=sv_SE.ISO8859-1
:charset=UTF-8:\
:lang=C.UTF-8:
#
# A collection of common class names - forward them all to 'default'
# (login would normally do this anyway, but having a class name
# here suppresses the diagnostic)
#
standard:\
:tc=default:
xuser:\
:tc=default:
staff:\
:tc=default:

# This PATH may be clobbered by individual applications. Notably, by default,
# rc(8), service(8), and cron(8) will all override it with a default PATH that
# may not include /usr/local/sbin and /usr/local/bin when starting services or
# jobs.
daemon:\
:path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin:\
:mail@:\
:memorylocked=128M:\
:tc=default:
news:\
:tc=default:
dialer:\
:tc=default:

#
# Root can always login
#
# N.B. login_getpwclass(3) will use this entry for the root account,
# in preference to 'default'.
root:\
:ignorenologin:\
:memorylocked=unlimited:\
:tc=default:

#
# Russian Users Accounts. Setup proper environment variables.
#
russian|Russian Users Accounts:\
:charset=UTF-8:\
:lang=ru_RU.UTF-8:\
:tc=default:


######################################################################
######################################################################
##
## Example entries
##
######################################################################
######################################################################

## Example defaults
## These settings are used by login(1) by default for classless users
## Note that entries like "cputime" set both "cputime-cur" and "cputime-max"
#
#default:\
# :cputime=infinity:\
# :datasize-cur=22M:\
# :stacksize-cur=8M:\
# :memorylocked-cur=10M:\
# :memoryuse-cur=30M:\
# :filesize=infinity:\
# :coredumpsize=infinity:\
# :maxproc-cur=64:\
# :openfiles-cur=64:\
# :priority=0:\
# :requirehome@:\
# :umask=022:\
# :tc=auth-defaults:
#
#
##
## standard - standard user defaults
##
#standard:\
# :copyright=/etc/COPYRIGHT:\
# :welcome=/var/run/motd:\
# :setenv=BLOCKSIZE=K:\
# :mail=/var/mail/$:\
# :path=~/bin /bin /usr/bin /usr/local/bin:\
# :manpath=/usr/share/man /usr/local/man:\
# :nologin=/var/run/nologin:\
# :cputime=1h30m:\
# :datasize=8M:\
# :vmemoryuse=100M:\
# :stacksize=2M:\
# :memorylocked=4M:\
# :memoryuse=8M:\
# :filesize=8M:\
# :coredumpsize=8M:\
# :openfiles=24:\
# :maxproc=32:\
# :priority=0:\
# :requirehome:\
# :passwordtime=90d:\
# :umask=002:\
# :ignoretime@:\
# :tc=default:
#
#
##
## users of X (needs more resources!)
##
#xuser:\
# :manpath=/usr/share/man /usr/local/man:\
# :cputime=4h:\
# :datasize=12M:\
# :vmemoryuse=infinity:\
# :stacksize=4M:\
# :filesize=8M:\
# :memoryuse=16M:\
# :openfiles=32:\
# :maxproc=48:\
# :tc=standard:
#
#
##
## Staff users - few restrictions and allow login anytime
##
#staff:\
# :ignorenologin:\
# :ignoretime:\
# :requirehome@:\
# :accounted@:\
# :path=~/bin /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin:\
# :umask=022:\
# :tc=standard:
#
#
##
## root - fallback for root logins
##
#root:\
# :path=~/bin /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin:\
# :cputime=infinity:\
# :datasize=infinity:\
# :stacksize=infinity:\
# :memorylocked=infinity:\
# :memoryuse=infinity:\
# :filesize=infinity:\
# :coredumpsize=infinity:\
# :openfiles=infinity:\
# :maxproc=infinity:\
# :memoryuse-cur=32M:\
# :maxproc-cur=64:\
# :openfiles-cur=1024:\
# :priority=0:\
# :requirehome@:\
# :umask=022:\
# :tc=auth-root-defaults:
#
#
##
## Settings used by /etc/rc
##
#daemon:\
# :coredumpsize@:\
# :coredumpsize-cur=0:\
# :datasize=infinity:\
# :datasize-cur@:\
# :maxproc=512:\
# :maxproc-cur@:\
# :memoryuse-cur=64M:\
# :memorylocked-cur=64M:\
# :openfiles=1024:\
# :openfiles-cur@:\
# :stacksize=16M:\
# :stacksize-cur@:\
# :tc=default:
#
#
##
## Settings used by news subsystem
##
#news:\
# :path=/usr/local/news/bin /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin:\
# :cputime=infinity:\
# :filesize=128M:\
# :datasize-cur=64M:\
# :stacksize-cur=32M:\
# :coredumpsize-cur=0:\
# :maxmemorysize-cur=128M:\
# :memorylocked=32M:\
# :maxproc=128:\
# :openfiles=256:\
# :tc=default:
#
#
##
## The dialer class should be used for a dialup PPP account
## Welcome messages/news suppressed
##
#dialer:\
# :hushlogin:\
# :requirehome@:\
# :cputime=unlimited:\
# :filesize=2M:\
# :datasize=2M:\
# :stacksize=4M:\
# :coredumpsize=0:\
# :memoryuse=4M:\
# :memorylocked=1M:\
# :maxproc=16:\
# :openfiles=32:\
# :tc=standard:
#
#
##
## Site full-time 24/7 PPP connection
## - no time accounting, restricted to access via dialin lines
##
#site:\
# :ignoretime:\
# :passwordtime@:\
# :refreshtime@:\
# :refreshperiod@:\
# :sessionlimit@:\
# :autodelete@:\
# :expireperiod@:\
# :graceexpire@:\
# :gracetime@:\
# :warnexpire@:\
# :warnpassword@:\
# :idletime@:\
# :sessiontime@:\
# :daytime@:\
# :weektime@:\
# :monthtime@:\
# :warntime@:\
# :accounted@:\
# :tc=dialer:\
# :tc=staff:
#
#
##
## Example standard accounting entries for subscriber levels
##
#
#subscriber|Subscribers:\
# :accounted:\
# :refreshtime=180d:\
# :refreshperiod@:\
# :sessionlimit@:\
# :autodelete=30d:\
# :expireperiod=180d:\
# :graceexpire=7d:\
# :gracetime=10m:\
# :warnexpire=7d:\
# :warnpassword=7d:\
# :idletime=30m:\
# :sessiontime=4h:\
# :daytime=6h:\
# :weektime=40h:\
# :monthtime=120h:\
# :warntime=4h:\
# :tc=standard:
#
#
##
## Subscriber accounts. These accounts have their login times
## accounted and have access limits applied.
##
#subppp|PPP Subscriber Accounts:\
# :tc=dialer:\
# :tc=subscriber:
#
#
#subshell|Shell Subscriber Accounts:\
# :tc=subscriber:
#
##
## If you want some of the accounts to use traditional UNIX DES based
## password hashes.
##
#des_users:\
# :passwd_format=des:\
# :tc=default:

Even if I write

zoor@FreeBSD-dell:~ $ LANG="sv_SE.UTF-8"
zoor@FreeBSD-dell:~ $ locale
LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_ALL=
zoor@FreeBSD-dell:~ $ sudo cap_mkdb /etc/login.conf
Lösenord:
zoor@FreeBSD-dell:~ $ sudo cap_mkdb .login_conf
zoor@FreeBSD-dell:~ $ locale
LANG=sv_SE.UTF-8
LC_CTYPE="sv_SE.UTF-8"
LC_COLLATE="sv_SE.UTF-8"
LC_TIME="sv_SE.UTF-8"
LC_NUMERIC="sv_SE.UTF-8"
LC_MONETARY="sv_SE.UTF-8"
LC_MESSAGES="sv_SE.UTF-8"
LC_ALL=

I still am not able to write swedish letters Ö Ä Å and more importantly... the "~" sign.
 
Back
Top