Page MenuHomeFreeBSD

Set the default locale to en_US.UTF-8
AbandonedPublic

Authored by bapt on Jan 8 2015, 11:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 22 2024, 8:42 PM
Unknown Object (File)
Feb 2 2024, 7:46 PM
Unknown Object (File)
Jan 4 2024, 9:15 AM
Unknown Object (File)
Nov 23 2023, 6:15 AM
Unknown Object (File)
Nov 13 2023, 9:12 AM
Unknown Object (File)
Sep 16 2023, 9:29 AM
Unknown Object (File)
Jun 27 2023, 12:41 PM
Unknown Object (File)
Jun 27 2023, 12:30 PM

Details

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bapt retitled this revision from to Set the default locale to en_US.UTF-8.
bapt updated this object.
bapt edited the test plan for this revision. (Show Details)
bapt added a reviewer: emaste.

Once /bin/sh is utf8 aware I think it is time to bring FreeBSD to the unicode world

Actually with the en_US.UTF-8

PC-BSD used to have a login.conf which was almost exactly like what you have
proposed. It set the locale by default:

https://github.com/pcbsd/pcbsd/blob/2e97491e9dd3fbdecd6090a364f298f7b80d7b4c/src-sh/pc-extractoverlay/desktop-overlay/etc/login.conf

Current PC-BSD has moved away from this, and now uses a stock login.conf
from FreeBSD.

What you have proposed is one way to set the locale by default,
but it is incomplete. We really need to modify our bsdconfig/bsdinstall scripts
to give a menu option to users to allow them to change the locale.

Can we collaborate with the PC-BSD folks and talk their scripts/knowledge
and use that to modify our bsdconfig?

They have already encountered this problem, and I would hate to see us reinvent the wheel. We (FreeBSD) would only take their stuff after it passed our review.

I'd be willing to write a patch for bsdinstall to do this. Do we know what PCBSD does now instead?

I am not running a PC-BSD system at the moment, so I don't know the current
behavior of PC-BSD with respect to setting locale. I asked Kris Moore to
participate in the conversation of this review to provide more details.

Quickly looking through the pcbsd repo, I see a few scripts dealing with setting locale:

https://github.com/pcbsd/pcbsd/blob/master/src-qt5/xtrafiles/local/share/pcbsd/scripts/set-lang.sh
https://github.com/pcbsd/pcbsd/blob/master/overlays/install-overlay/etc/profile
https://github.com/pcbsd/pcbsd/blob/master/src-sh/pcbsd-utils/pc-sysinstall/backend/functions-localize.sh

I don't understand how all the pieces fit together, so hopefully Kris
can chime in on this conversation and help out.

Let someone else handle this change.

Our "stock" freebsd login.conf is modified during installation, so the default becomes "en_US.UTF-8" or "<FOO>.UTF-8". We've been doing this for a couple of years now at least. The only minor issues we've run into is "forcing" some Qt apps to do UTF-8 by default, but that's about it.

FWIW selecting a locale during install time seems to me to be the best approach.

@kmoore: where is the code in the PCBSD github repo that deals with setting
the locale? I saw the old verion of login.conf which explicitly set the value in https://github.com/pcbsd/pcbsd/blob/2e97491e9dd3fbdecd6090a364f298f7b80d7b4c/src-sh/pc-extractoverlay/desktop-overlay/etc/login.conf , but that file is no longer there, and a lot of code has moved around in the PC-BSD github.

We should take whatever logic PC-BSD has for setting the locale, and either
import it directly into FreeBSD, or port it to bsdconfig.

Ok, I did some digging, haven't looked at this bit of code in PC-BSD in a while. Our old method was to set the UTF-8 stuff in /etc/login.conf during the installation, nothing special.

Right now we are setting LANG="en_UFS.UTF-8" in /etc/profile and /etc/csh.cshrc. I don't recall the reasoning for why we switched to doing it this way. I think it may have been a work-around to avoid some bugs setting UTF-8 in login.conf directly, but still wanting it for shell.

Either way, I think you guys should enable it and if we run into bugs again, we will solve them as they come.

@kmoore:

Hardcoding en_US.UTF-8 in login.conf or /etc/profile is not hard to do,
but changing it is more tricky, because files like /etc/login.conf look easier
to edit by hand, rather than parse/modify by a program.

I suggest that we write a bsdconfig module that presents the user with a menu
with a locale to choose from. For an initial go, the default choice would be no
locale. After the user chooses the locale, then /etc/login.conf would be modified.

Do you have code from PC-BSD that can modify /etc/login.conf for this purpose?

We didn't have anything too fancy to do this. All we did was hard-code in en_US.UTF-8 and then have our installer script sed that to whatever:

sed -i'' "s/lang=en_US.UTF-8/lang=${LOCALE}/g" ${FSMNT}/etc/login.conf

I would expect you want to do something similar, after prompting the user for their preferred locale.