Sha256: 98eda44c3bf91de966f05a20b9bb3b063f427b3c4d12dbe1f6347e1f71372f84

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path("spec_helper", File.dirname(__FILE__))

include FastGettext
FastGettext.add_text_domain('test',:path=>File.join(File.dirname(__FILE__),'locale'))
FastGettext.text_domain = 'test'
FastGettext.available_locales = ['en','de']
FastGettext.locale = 'de'

include FastGettext

describe FastGettext do
  describe :_ do
    it "translates simple text" do
      _('car').should == 'Auto'
    end
    it "returns msgid if not translation was found" do
      _('NOT|FOUND').should == 'NOT|FOUND'
    end
  end

  describe :n_ do
    it "translates pluralized" do
      n_('Axis','Axis',1).should == 'Achse'
      n_('Axis','Axis',2).should == 'Achsen'
    end
    it "returns the appropriate msgid if no translation was found" do
      n_('NOTFOUND','NOTFOUNDs',1).should == 'NOTFOUND'
      n_('NOTFOUND','NOTFOUNDs',2).should == 'NOTFOUNDs'
    end
  end

  describe :s_ do
    it "translates simple text" do
      _('car').should == 'Auto'
    end
    it "returns cleaned msgid if a translation was not found" do
      s_("XXX|not found").should == "not found"
    end
    it "can use a custom seperator" do
      s_("XXX/not found",'/').should == "not found"
    end
  end

  describe :N_ do
    it "returns the msgid" do
      N_('XXXXX').should == 'XXXXX'
    end
  end

  describe :Nn_ do
    it "returns the msgids as array" do
      Nn_('X','Y').should == ['X','Y']
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grosser-fast_gettext-0.2.0 spec/fast_gettext_spec.rb
grosser-fast_gettext-0.2.1 spec/fast_gettext_spec.rb
grosser-fast_gettext-0.2.2 spec/fast_gettext_spec.rb
grosser-fast_gettext-0.2.3 spec/fast_gettext_spec.rb
grosser-fast_gettext-0.2.4 spec/fast_gettext_spec.rb