-
Notifications
You must be signed in to change notification settings - Fork 28
/
locale.rb
41 lines (39 loc) · 1.24 KB
/
locale.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
meta :locale do
def locale_regex locale_name
/#{locale_name}\.utf-?8/i
end
def local_locale locale_name
shell('locale -a').split("\n").detect {|l|
l[locale_regex(locale_name)]
}
end
end
dep 'set.locale', :locale_name do
deprecated! "2013-12-12", :method_name => "'benhoskings:set.locale'", :callpoint => false, :instead => "'common:set.locale'"
locale_name.default!('en_AU')
requires 'exists.locale'.with(locale_name)
met? {
shell('locale').val_for('LANG')[locale_regex(locale_name)]
}
meet {
if Babushka.host.matches?(:arch)
sudo("echo 'LANG=#{local_locale(locale_name)}' > /etc/locale.conf")
elsif Babushka.host.matches?(:apt)
sudo("echo 'LANG=#{local_locale(locale_name)}' > /etc/default/locale")
elsif Babushka.host.matches?(:bsd)
sudo("echo 'LANG=#{local_locale(locale_name)}' > /etc/profile")
end
}
after {
log "Setting the locale doesn't take effect until you log out and back in."
}
end
dep 'exists.locale', :locale_name do
deprecated! "2013-12-12", :method_name => "'benhoskings:exists.locale'", :callpoint => false, :instead => "'common:exists.locale'"
met? {
local_locale(locale_name)
}
meet {
shell "locale-gen #{locale_name}.UTF-8", :log => true
}
end