# frozen_string_literal: true require 'spec_helper' require 'spree/i18n' RSpec.describe "i18n" do before do # This reload avoids an issue with I18n.available_locales being cached I18n.reload! I18n.backend.store_translations(:en, { spree: { i18n: { this_file_language: "English" }, foo: "bar", bar: { foo: "bar within bar scope", invalid: nil, legacy_translation: "back in the day..." }, invalid: nil, legacy_translation: "back in the day..." } }) end after do I18n.reload! end it "translates within the spree scope" do expect(Spree::Deprecation).to receive(:warn).twice expect(Spree.t(:foo)).to eql("bar") expect(Spree.translate(:foo)).to eql("bar") end it "prepends a string scope" do expect(Spree::Deprecation).to receive(:warn) expect(Spree.t(:foo, scope: "bar")).to eql("bar within bar scope") end it "prepends to an array scope" do expect(Spree::Deprecation).to receive(:warn) expect(Spree.t(:foo, scope: ["bar"])).to eql("bar within bar scope") end it "returns two translations" do expect(Spree::Deprecation).to receive(:warn) expect(Spree.t([:foo, 'bar.foo'])).to eql(["bar", "bar within bar scope"]) end it "returns reasonable string for missing translations" do expect(Spree::Deprecation).to receive(:warn) expect(Spree.t(:missing_entry)).to include("