mattetti / merb_babel

Merb Babel is a dead simple translation/localization tool for Merb

This URL has Read+Write access

genki (author)
Fri Jan 16 11:43:50 -0800 2009
Matt Aimonetti (committer)
Fri Jan 16 16:15:00 -0800 2009
merb_babel / spec / m_l10n_spec.rb
100644 55 lines (44 sloc) 1.993 kb
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require File.dirname(__FILE__) + '/spec_helper'
 
describe "ML10n" do
  
  before(:each) do
    @lang_test_path = File.expand_path(File.dirname(__FILE__) + "/lang")
    @lang_test_path_2 = File.expand_path(File.dirname(__FILE__) + "/other_lang_dir")
    ML10n.reset_localization_files_and_dirs!
  end
 
  after(:each) do
    ML10n.reset_localizations!
  end
  
  it "should have a list of localization directories" do
    ML10n.localization_dirs.should == Merb::Plugins.config[:merb_babel][:localization_dirs]
  end
  
  it "should be able to add a new localization directory" do
    ML10n.add_localization_dir(@lang_test_path)
    ML10n.localization_dirs.include?(@lang_test_path)
  end
  
  it "should have a list of localization source files" do
    ML10n.localization_files.should == []
    ML10n.add_localization_dir(@lang_test_path)
    ML10n.localization_files.include?("#{@lang_test_path}/en.yml").should be_true
    ML10n.localization_files.include?("#{@lang_test_path}/en-US.yml").should be_true
  end
  
  it "should load localization files and have them available" do
    ML10n.add_localization_dir(@lang_test_path)
    ML10n.load_localization!
    ML10n.localizations['en']['right'].should == 'right'
    ML10n.localizations['en']['left'].should == 'left'
    ML10n.localizations['en']['US']['greetings'].should == 'Howdie'
  end
  
  it "should load more localization files and have them available" do
    ML10n.add_localization_dir(@lang_test_path)
    ML10n.load_localization!
    ML10n.localizations['en']['right'].should == 'right'
    ML10n.localizations.has_key?('fr').should be_false
    
    ML10n.add_localization_dir(@lang_test_path_2)
    ML10n.load_localization!
    ML10n.localizations['en']['right'].should == 'right'
    ML10n.localizations.has_key?('fr').should be_true
    ML10n.localizations['fr']['right'].should == 'la droite'
    ML10n.localizations['fr']['left'].should == 'la gauche'
    ML10n.localizations['fr']['greetings'].should == 'Salut'
  end
  
end