Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Request to change the LC_ALL default setting and add the possibility to unset LC_ALL. #22

Open
janskarvall opened this issue Jan 20, 2017 · 2 comments

Comments

@janskarvall
Copy link

Cookbook version

2.0.0

Chef-client version

12.17.44

Platform Details

ubuntu 16.04

Scenario:

I'm struggling with getting locale setting to my likings for a node.

The particular problem I have is to get Thunderbird on my Ubuntu 16.04 Desktop host showing dates in Swedish format, while having English(United States) as the preferred format.

I get the wanted behaviour when I have English(United States) as the preferred format in Ubuntu's System Settings...>Language Support>Language and have chosen Swedish in Settings...>Language Support>Regional Formats and unset LC_ALL (e.g. by removing it from /etc/default/locale).

It seems to me that the only way to "unset" LC_ALL, when using the locale cookbook, is to set the attribute locale['lc_all'] to " ". (Resulting in LC_ALL= rather than unsetting it.) .
Setting it to "" (or, I guess nil - have not tested) sets LC_ALL to locale['lang'] which defaults to "en_US.utf8".

At https://wiki.debian.org/Locale it is stated that "Using LC_ALL is strongly discouraged as it overrides everything. Please use it only when testing and never set it in a startup file.".

So, I wonder why the cookbook sets LC_ALL to locale['lang'], which defaults to "en_US.utf8". Wouldn't it be better to unset LC_ALL as default?

Also, I think that it would be good to be able to unset LC_ALL by e.g. setting the attribute locale['lc_all'] to nil.

Steps to Reproduce:

This is how I am currently installing the Swedish language and setting LC_ALL to empty in my recipe. I am using locale-gen 0.0.3:

node.default['localegen']['lang'] = ["en_US", "en_US.UTF-8", "sv_SE", "sv_SE.UTF-8"]
package 'language-pack-sv'
package 'language-pack-sv-base'
package 'language-pack-gnome-sv'
package 'language-pack-gnome-sv-base'
include_recipe 'locale-gen'
node.default['locale']['lc_all'] =  " "
include_recipe 'locale'

It gives the following environment setting:

$ env | grep LC_
LC_PAPER=sv_SE.UTF-8
LC_ADDRESS=sv_SE.UTF-8
LC_MONETARY=sv_SE.UTF-8
LC_NUMERIC=sv_SE.UTF-8
LC_ALL=
LC_TELEPHONE=sv_SE.UTF-8
LC_IDENTIFICATION=sv_SE.UTF-8
LC_MEASUREMENT=sv_SE.UTF-8
LC_TIME=sv_SE.UTF-8
LC_NAME=sv_SE.UTF-8

This gives the behaviour I want. Unsetting LC_ALL rather than setting it empty also gives the wanted behaviour.

@lamont-granquist
Copy link
Contributor

I pretty much agree, my settings in my .envrc are:

export LANG=en_US.UTF-8
unset LC_ALL
export LC_COLLATE=C

cookbook should probably take nil or the empty string and translate that to an unset, and should default to setting only LANG and not LC_ALL.

@lamont-granquist
Copy link
Contributor

it looks like this cookbook only supports LANG and LC_ALL and nothing else? that should get fixed as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants