Only set up default locale on FixMyStreet install.#24
Conversation
FixMyStreet uses the default locale in order to have working URIs with floating point numbers. This could be moved to the FixMyStreet install script with its next release and then removed from here.
bin/install-site.sh
Outdated
There was a problem hiding this comment.
We probably want to make the locales available to all systems so that the SSH session can pick the one it requires.
There was a problem hiding this comment.
All generate_locales does is install language-pack-en (if present, so Ubuntu) and add an en_GB locale. I don't think it does anything that prevents making locales available to any system.
There was a problem hiding this comment.
Installation of the locales package runs locale-gen postinst, so any locale chosen at server set up is already available. I'm not sure it feels right for an install script to install every possible locale, just in case? Vagrant's puppetlabs/debian-7.4-64-nocm, puppetlabs/debian-6.0.9-64-nocm, and ubuntu/precise64 all have a default of en_US.UTF-8, for what it's worth. If the default is None, then yes, you need to make sure the locale passed by SSH is installed on the server in order for it to work. Perhaps this script should instead do the following:
- Check what locale has come over SSH - if it's UTF-8, make sure that it is installed and that the server has no default, and then continue;
- Otherwise, check if the server has a default, and that it's UTF-8, and if so continue;
- Otherwise, set up
en_GB.UTF-8as now so that installation will proceed smoothly (e.g. in mapit's case, install_postgis requires a UTF-8 locale).
Does that work?
Rather than always installing en_GB.UTF-8 and setting it as the default, we instead do the following: * If the current LANG (perhaps passed in via SSH) is UTF-8, make sure it is generated, and remove any default locale setup if different; * If it isn't, but the default locale is UTF-8, use that; * If not, set up en_GB.UTF-8 as before.
|
Have added commit to implement different locale setup. Would be good to have a number of eyes checking this @garethrees @mhl :) |
|
Running against the puppetlabs/squeeze VM I get: /vagrant/install.sh: line 53: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)Here's some more info: http://pastie.org/private/9ujduo5nfmqckjjoobsfxg My terminal sends the locale I want debug1: Sending env LANG = en_GB.UTF-8and the script seems to generate it Generating locale en_GB... donebut then we get the warning and the locale remains as /vagrant/install.sh: line 53: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
done
vagrant@debian-607-x64-vbox4210-nocm:~$ locale
LANG=en_USAfter logging out and starting a new SSH session: Linux debian-607-x64-vbox4210-nocm 2.6.32-5-amd64 #1 SMP Fri Feb 15 15:39:52 UTC 2013 x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 21 11:16:39 2014 from 192.168.33.1
-bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
vagrant@debian-607-x64-vbox4210-nocm:~$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=en_GB.UTF-8 |
|
@garethrees You didn't set |
|
Separate issue - if LANG is an okay UTF-8, but not installed on the server, my first |
There was a problem hiding this comment.
I haven't seen lowercase $lang defined anywhere, so not sure where that's coming from.
There was a problem hiding this comment.
That's a typo, ta; that whole section needs work as per #24 (comment)
Oops. Updated http://pastie.org/private/dnl3fu91emrgxdwl9dsq (including 975e309).
|
|
Yes, that will happen if you run the install script with bash rather than sh as the instructions/Vagrantfile do, due to the differing behaviours of |
|
Ah, yeah, running through I notice it still needs a logout to pick up the new locale, but interestingly appending |

FixMyStreet uses the default locale in order to have working URIs with
floating point numbers. This could be moved to the FixMyStreet install
script with its next release and then removed from here.