On 10/10/19 8:12 AM, Pierre Labastie via blfs-dev wrote:
Hi,

I've eventually managed to produce a very preliminary version of a standalone localed daemon at https://github.com/pierre-labastie/blocaled.

I'd like this daemon to be usable on blfs (SysV), because it is needed for smooth operation of gnome. But we have a problem with configuration files. localed assumes there are three configuration files: - one for locale settings, containing variable assignments in shell syntax, for setting LANG and LC_* variables. On systemd, this is the /etc/locale file. On openrc, this is the /etc/conf.d/02locale file. - one for keyboard settings, containing variable assignments in shell syntax, for setting KEYBOARD and KEYBOARD_TOGGLE variables (this file may contain other assignments, for example setting FONT, but the other variables are not used by localed). On systemd, this the /etc/vconsole file. On openrc, this is the /etc/conf.d/keymaps file. - one for X11 keyboard settings, in Xorg conf syntax, for setting XkbLayout, XkbModel, XkbVariant and XkbOptions. On systemd, this is the /etc/X11/xorg.conf.d/00-keyboard.conf file. On openrc, this is the /etc/X11/xorg.conf.d/30-keyboard.conf file.

Right now, the name of those files are hard coded in the program. I plan to at least give users the choice of the names at build time (and maybe later add a config file containing those filenames, that would be parsed when the daemon starts). On BLFS, two of those files are straightforward to find: /etc/sysconfig/console for the keyboard settings, and /etc/X11/xorg.conf.d/xx-whatever.conf for the X11 keyboard. But the locale is set in /etc/profile or /etc/profile.d/i18n.sh, in a format which is _not_ compatible with what is expected by the daemon (the "export" keyword is not expected)...

So here is a proposition:
- define a locale config file in a format expected by the daemon (say /etc/sysconfig/locale)
- replace the current /etc/profile.d/i18n.fr with:
---------------------
source /etc/sysconfig/locale

This needs to be:

[ -r /etc/sysconfig/locale ] && . /etc/sysconfig/locale

If the file is not present and readable, do not complain.


for var in LANG LC_TYPE LC_NUMERIC LC_TIME \
                 LC_COLLATE LC_MONETARY LC_MESSAGES \
                 LC_PAPER LC_NAME LC_ADDRESS \
                 LC_TELEPHONE LC_MEASUREMENTS LC_IDENTIFICATION; do

I prefer vertical alignment sorted for easier reading:

for var in LANG            \
           LC_ADDRESS      \
           LC_COLLATE      \
           LC_MEASUREMENTS \
           LC_MESSAGES     \
           LC_MONETARY     \
           LC_NAME         \
           LC_NUMERIC      \
           LC_PAPER        \
           LC_TELEPHONE    \
           LC_TIME         \
           LC_TYPE; do

# Add LANGUAGE and LC_ALL to the above list if needed
[ -n "${!var}" ] && export $var
done
---------------------
This replacement would be done on the blocaled page, so that users not needing the daemon can have the same files as usual.

Is blocaled needed if you just need LANG?  What I have now is:

LANG=en_US.utf8
LANGUAGE=

LC_ALL should probably not be set. It overrides all the LC* variables. If it is in /etc/sysconfig/locale should probably be considered a bad configuration.

LANGUAGE is used to set messages languages (as LC_MESSAGES) to a multi-valued value, e.g., setting it to fr:de:en will use French messages where they exist; if not, it will use German messages, and will fall back to English if neither German nor French messages are available.

If LANGUAGE is in /etc/sysconfig/locale, I think it probably should be set.

  -- Bruce


Would it be OK?

Another possibility is to write a parser for our i18n.sh (both reading and writing!), but I do  not like it for two reasons:
- that would not be compatible anymore with other distros
- that might take a long time to get it right and find all corner cases...

Regards
Pierre


--
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to