require 'spec_helper'

describe 'Translations' do

  before :all do
    I18n.backend.store_translations :en, :test_number => "Test number %{number}"
    I18n.locale=:ca
  end

  it "should fall back to the default locale when the key doesn't exist" do
    I18n.t(:test_number, :number=>1).should == "Test number 1"
  end

  it "should fall back to the default locale when the interpolation doesn't work" do
    I18n.backend.store_translations :ca, :test_number => "Test número %{numero}"
    I18n.t(:test_number, :number=>1).should == "Test number 1"
  end

  it "should translate normally when everything is alright" do
    I18n.backend.store_translations :ca, :test_number => "Test número %{number}"
    I18n.t(:test_number, :number=>1).should == "Test número 1"
  end

end

require 'spec_helper'

describe 'Translations' do

  before do
    I18n.backend.store_translations :en, :test_number => "Test number %{number}"
    I18n.locale=:ca
  end

  after do
    I18n.locale=:en
  end

  it "should fall back to the default locale when the key doesn't exist" do
    I18n.t(:test_number, :number=>1).should == "Test number 1"
  end

  it "should fall back to the default locale when the interpolation doesn't work" do
    I18n.backend.store_translations :ca, :test_number => "Test número %{numero}"
    I18n.t(:test_number, :number=>1).should == "Test number 1"
  end

  it "should translate normally when everything is alright" do
    I18n.backend.store_translations :ca, :test_number => "Test número %{number}"
    I18n.t(:test_number, :number=>1).should == "Test número 1"
  end

end

Reset i18n locale back to en in specs
Reset i18n locale back to en in specs
