Permalink
Browse files

add support for CentOS and make more robust

  • Loading branch information...
1 parent ae51743 commit f6fb93f5e6e19e43f28d84a181ad8dc325e534df @dlutzy committed May 2, 2012
Showing with 39 additions and 11 deletions.
  1. +16 −3 README.md
  2. +1 −1 attributes/default.rb
  3. +2 −1 metadata.rb
  4. +20 −5 recipes/default.rb
  5. +0 −1 templates/default/locale.erb
View
@@ -1,17 +1,30 @@
Description
===========
-Sets system locale
+Sets default system locale
+
+You can see which languages are available by
+$ locale -a
+
+On debian based systems you can set the locale by running
+# update-locale LANG={lang}
+e.g.
+# update-locale LANG=en_AU.utf8
+
+It updates the file /etc/default/locale
+
+On rhel based systems you can set default locale updating /etc/sysconfig/i18n
+There doesn't seem to be a command line tool to update this file?!?
Requirements
============
-Tested on Ubuntu
+Tested on Ubuntu, CentOS
Attributes
==========
-* `node[:locale][:lang]` -- defaults to "en_US.UTF-8"
+* `node[:locale][:lang]` -- defaults to "en_US.utf8"
Usage
=====
View
@@ -1 +1 @@
-default[:locale][:lang] = "en_US.UTF-8"
+default[:locale][:lang] = "en_US.utf8"
View
@@ -3,7 +3,8 @@
license "Apache 2.0"
description "Installs/Configures locale"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "0.0.1"
+version "0.0.2"
supports "ubuntu"
supports "debian"
+supports "centos"
View
@@ -17,9 +17,24 @@
# limitations under the License.
#
-template "/etc/default/locale" do
- source "locale.erb"
- mode "644"
- variables( :lang => node[:locale][:lang] )
- action :create_if_missing
+if platform?("ubuntu", "debian")
+
+ package "locales" do
+ action :install
+ end
+
+ execute "Update locale" do
+ command "update-locale LANG=#{node[:locale][:lang]}"
+ action :nothing
+ end
+
+end
+
+if platform?("ubuntu", "redhat", "centos", "fedora")
+
+ execute "Update locale" do
+ command "locale -a | grep ^#{node[:locale][:lang]}$ && sed -i 's|LANG=.*|LANG=#{node[:locale][:lang]}|' /etc/sysconfig/i18n"
+ end
+
end
+
@@ -1 +0,0 @@
-LANG=<%= @lang %>

0 comments on commit f6fb93f

Please sign in to comment.