Commit 1422a69b6f86e89f2a77121c864808a5711bfbcc
Committed by
Daniela Feitosa
1 parent
534114b8
Exists in
master
and in
28 other branches
Re-introduce possibility of setting locales list
Signed-off-by: Daniela Soares Feitosa <danielafeitosa@colivre.coop.br>
Showing
2 changed files
with
13 additions
and
1 deletions
Show diff stats
lib/noosfero.rb
@@ -10,7 +10,7 @@ module Noosfero | @@ -10,7 +10,7 @@ module Noosfero | ||
10 | 10 | ||
11 | class << self | 11 | class << self |
12 | def locales | 12 | def locales |
13 | - { | 13 | + @locales ||= { |
14 | 'en' => 'English', | 14 | 'en' => 'English', |
15 | 'pt' => 'Português', | 15 | 'pt' => 'Português', |
16 | 'fr' => 'Français', | 16 | 'fr' => 'Français', |
@@ -21,6 +21,7 @@ module Noosfero | @@ -21,6 +21,7 @@ module Noosfero | ||
21 | 'eo' => 'Esperanto' | 21 | 'eo' => 'Esperanto' |
22 | } | 22 | } |
23 | end | 23 | end |
24 | + attr_writer :locales | ||
24 | attr_accessor :default_locale | 25 | attr_accessor :default_locale |
25 | def available_locales | 26 | def available_locales |
26 | @available_locales ||= | 27 | @available_locales ||= |
test/unit/noosfero_test.rb
@@ -84,4 +84,15 @@ class NoosferoTest < ActiveSupport::TestCase | @@ -84,4 +84,15 @@ class NoosferoTest < ActiveSupport::TestCase | ||
84 | assert_equal 'localhost', Noosfero.default_hostname | 84 | assert_equal 'localhost', Noosfero.default_hostname |
85 | end | 85 | end |
86 | 86 | ||
87 | + should 'be able to override locales' do | ||
88 | + original_locales = Noosfero.locales | ||
89 | + | ||
90 | + english_only = { 'en' => 'English' } | ||
91 | + Noosfero.locales = english_only | ||
92 | + assert_equal english_only, Noosfero.locales | ||
93 | + | ||
94 | + # cleanup | ||
95 | + Noosfero.locales = original_locales | ||
96 | + end | ||
97 | + | ||
87 | end | 98 | end |