# Localization and changes to /etc/login.conf



## anbj (Feb 17, 2021)

Hi all,

First, I want to pardon my ignorance. Feel free to bash me (pun intended).

I've been reading about localization (https://docs.freebsd.org/en/books/handbook/l10n/#using-localization).

I've used the "Shell Startup File Method" (editing ~/.login_conf), but now that I'm more comfortable with FreeBSD I want to use the "Login Classes Method ". Same settings for every possible shell.

I need to use the letters æøå; so I need a non-default charset, more specifically nb_NO.UTF-8.

So what I have to do is apparently clear (as per handbook):

- `vim /etc/login.conf`

- add `:charset=nb_NO.UTF-8:` to the default class (all users on my system use this)

-update, `cap_mkdb /etc/login.conf`

If I now create a new user, the charset is not nb_NO.UTF-8. ÆØÅ does not work. I assume it is the default charset being used.

Additional question:
Are settings in /etc/login.conf only applied when a user is created? Or is it loaded every time a user logs in or every time the system boots? If I make a change in /etc/login.conf, how would I make those changes apply to existing users? I've been playing around to try to figure this out, but I'm confused.

Additional question #2
I thought the whole point of UTF-8 is that it's able to print/input all kind of characters. Why then, is necessary to specify a LanguageCode_CountryCode (as in LanguageCode_CountryCode.UTF-8)? Why does UTF-8 care about this?

I've read:
* login.conf(5)
* https://forums.freebsd.org/threads/freebsd-12-2-localization-issue.78664/
* https://forums.freebsd.org/threads/what-happened-to-etc-profile.78406/#post-489962
* https://forums.freebsd.org/threads/localization-and-character-set-in-console.62051/
* https://forums.freebsd.org/threads/setting-locale-accented-characters-in-console.71696/

Thanks for any enlightening inputs.


----------



## SirDice (Feb 17, 2021)

anbj said:


> I need to use the letters æøå; so I need a non-default charset, more specifically nb_NO.UTF-8.


nb_NO.UTF-8 is a language setting. UTF-8 is the character set. The charset is already at UTF-8 by default on most new installs (you may have migrated from an older version that didn't have it). 



anbj said:


> Are settings in /etc/login.conf only applied when a user is created? Or is it loaded every time a user logs in or every time the system boots? If I make a change in /etc/login.conf, how would I make those changes apply to existing users? I've been playing around to try to figure this out, but I'm confused.


They're applied when the user logs in.


----------



## anbj (Feb 17, 2021)

SirDice,

Two sentences and I've learned a lot. Thank you.

I just did a new install of 13-BETA2 and æøå works right out of the box. Great. This is a recent change, right? I was running 13-CURRENT from some months ago, where it did not work out of the box.


----------



## SirDice (Feb 17, 2021)

anbj said:


> This is a recent change, right?


UTF-8 has been the default for a while now. Not sure when exactly, I think it was around the 10.x version.


----------



## anbj (Feb 17, 2021)

Hmm, thats strange. Then it should be working out of the box in 12.1, 12.2, and 13-* (which are the only versions I've been using), but I'm fairly certain it did not.


----------



## SirDice (Feb 17, 2021)

No, I do believe there were some issues that needed to be ironed out. Most of the time it still required some configuration. Sounds like they fixed all of those with 13.0 

I'm Dutch but I rarely write anything in Dutch, so I have very little need for some of the Dutch specific characters like ë or é. Most of the time I don't type them and just let a spellchecker fix those. So I typically leave everything on en_US or en_GB (sometimes pick GB to "fix" the date to D/M/Y instead of the American M/D/Y).


----------



## anbj (Feb 17, 2021)

That makes sense. Thanks again, SirDice.

I'm Norwegian, and my needs for the special characters are not that great either, but still, it's always a pain when they're not readily available. People who only write english dont know how lucky they are


----------



## anbj (Feb 25, 2021)

For anyone else dealing with this;

I've found that on 12.2, it appears that both `:charset=UTF.8:` and `:lang=C.UTF-8:` have to be set in /etc/login.conf in order to use UTF-8. I guess it does not matter which `:lang:` you use, as long as it's been set. On 13 it is enough to set only `:charmap=UTF-8:`. I do not guarantee that this is correct, but this is my experience.


----------



## zirias@ (Feb 25, 2021)

Be aware that /etc/login.conf (precisely the database generated from it) only works for actual logins. If you want to pre-select a locale for other processes (like for example an X display manager started from rc), you could add environment variables to /etc/profile:

```
LANG=de_DE.UTF-8; export LANG
CHARSET=UTF-8; export CHARSET
```


----------



## T-Daemon (Feb 25, 2021)

anbj said:


> On 13 it is enough to set only `:charmap=UTF-8:`.


On stable/13 there is no need to set anything, the default locale is already set to UTF-8 (since November 2020 when 13 was CURRENT):






						src - FreeBSD source tree
					






					cgit.freebsd.org
				









						login.conf « login « usr.bin - src - FreeBSD source tree
					






					cgit.freebsd.org


----------



## anbj (Feb 25, 2021)

T-Daemon said:


> On stable/13 there is no need to set anything, the default locale is already set to UTF-8 (since November 2020 when 13 was CURRENT):
> 
> 
> 
> ...



You're absolutely right. I'm also contradicting myself (ref. earlier post). Thank you T-Daemon.



Zirias said:


> Be aware that /etc/login.conf (precisely the database generated from it) only works for actual logins. If you want to pre-select a locale for other processes (like for example an X display manager started from rc), you could add environment variables to /etc/profile:
> 
> ```
> LANG=de_DE.UTF-8; export LANG
> ...



Good info, thanks Zirias.


----------

