├── .github ├── FUNDING.yml ├── stale.yml └── workflows │ └── test.yml ├── Gemfile ├── lib ├── globalize-versioning.rb └── globalize │ ├── versioning │ ├── version.rb │ ├── instance_methods.rb │ └── paper_trail.rb │ └── versioning.rb ├── test ├── data │ ├── models │ │ ├── options_post.rb │ │ ├── post.rb │ │ └── legacy_post.rb │ ├── models.rb │ └── schema.rb ├── globalize-versioning │ ├── legacy_versioning_test.rb │ ├── options_test.rb │ └── versioning_test.rb └── test_helper.rb ├── gemfiles ├── rails_5.1.7.gemfile ├── rails_5.2.5.gemfile ├── rails_7.0.0.gemfile ├── rails_4.2.11.3.gemfile ├── rails_6.0.3.6.gemfile └── rails_6.1.3.1.gemfile ├── .gitignore ├── CHANGELOG.md ├── Rakefile ├── LICENSE ├── globalize-versioning.gemspec └── readme.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [parndt] 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /lib/globalize-versioning.rb: -------------------------------------------------------------------------------- 1 | require_relative 'globalize/versioning' 2 | 3 | -------------------------------------------------------------------------------- /test/data/models/options_post.rb: -------------------------------------------------------------------------------- 1 | class OptionsPost < ActiveRecord::Base 2 | self.table_name = :posts 3 | end 4 | -------------------------------------------------------------------------------- /test/data/models.rb: -------------------------------------------------------------------------------- 1 | Dir[File.expand_path('../models/**/*.rb', __FILE__)].each do |model| 2 | require model 3 | end 4 | -------------------------------------------------------------------------------- /gemfiles/rails_5.1.7.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec path: "../" 4 | 5 | gem 'activerecord', '~> 5.1.7' 6 | -------------------------------------------------------------------------------- /gemfiles/rails_5.2.5.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec path: "../" 4 | 5 | gem 'activerecord', '~> 5.2.5' 6 | -------------------------------------------------------------------------------- /gemfiles/rails_7.0.0.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec path: "../" 4 | 5 | gem 'activerecord', '~> 7.0.0' 6 | -------------------------------------------------------------------------------- /gemfiles/rails_4.2.11.3.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec path: "../" 4 | 5 | gem 'activerecord', '~> 4.2.11.3' 6 | -------------------------------------------------------------------------------- /gemfiles/rails_6.0.3.6.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec path: "../" 4 | 5 | gem 'activerecord', '~> 6.0.3.6' 6 | -------------------------------------------------------------------------------- /gemfiles/rails_6.1.3.1.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec path: "../" 4 | 5 | gem 'activerecord', '~> 6.1.3.1' 6 | -------------------------------------------------------------------------------- /test/data/models/post.rb: -------------------------------------------------------------------------------- 1 | class Post < ActiveRecord::Base 2 | attribute :title 3 | translates :title, :versioning => :paper_trail 4 | end 5 | -------------------------------------------------------------------------------- /lib/globalize/versioning/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Globalize 4 | module Versioning 5 | VERSION = '0.5.0' 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | doc 2 | spec/spec/db/* 3 | vendor 4 | NOTES 5 | .DS_Store 6 | .bundle 7 | Gemfile.lock 8 | .rvmrc 9 | *.sw* 10 | *.gem 11 | .rbx 12 | gemfiles/*.lock 13 | -------------------------------------------------------------------------------- /test/data/models/legacy_post.rb: -------------------------------------------------------------------------------- 1 | class LegacyPost < ActiveRecord::Base 2 | self.table_name = :posts 3 | attribute :title 4 | translates :title, :versioning => true 5 | end 6 | -------------------------------------------------------------------------------- /lib/globalize/versioning/instance_methods.rb: -------------------------------------------------------------------------------- 1 | module Globalize 2 | module Versioning 3 | module InstanceMethods 4 | def rollback 5 | translation_caches[::Globalize.locale] = translation.paper_trail.previous_version 6 | end 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.2.0 (2016-02-28) 2 | 3 | * added support for paper_trail 4 4 | 5 | # 0.1.0 (2015-02-24) 6 | 7 | * added support for Globalize 5 and Rails 4.2 8 | 9 | # 0.1.0.alpha.1 (2014-01-04) 10 | 11 | * first public pre-release supporting Rails 3.2, 4.0 and 4.1 with 12 | Globalize ~> 4.0 13 | -------------------------------------------------------------------------------- /test/globalize-versioning/legacy_versioning_test.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../test_helper', __FILE__) 2 | 3 | class LegacyVersioningTest < MiniTest::Spec 4 | 5 | it 'defaults to paper_trail versioning when passed :versioning => true' do 6 | post = LegacyPost.create!(:title => 'title v1') 7 | assert_equal 1, post.translation.versions.length 8 | 9 | post.update :title => 'title v2' 10 | 11 | post.rollback 12 | assert_equal 'title v1', post.title 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rdoc/task' 4 | require 'bundler/gem_tasks' 5 | 6 | desc 'Default: run unit tests.' 7 | task :default => :test 8 | 9 | desc 'Run all tests.' 10 | Rake::TestTask.new(:test) do |t| 11 | t.libs << 'lib' 12 | t.pattern = 'test/**/*_test.rb' 13 | t.verbose = true 14 | end 15 | 16 | desc 'Generate documentation.' 17 | Rake::RDocTask.new(:rdoc) do |rdoc| 18 | rdoc.rdoc_dir = 'rdoc' 19 | rdoc.title = 'Globalize Versioning' 20 | rdoc.options << '--line-numbers' << '--inline-source' 21 | rdoc.rdoc_files.include('README') 22 | rdoc.rdoc_files.include('lib/**/*.rb') 23 | end 24 | -------------------------------------------------------------------------------- /test/data/schema.rb: -------------------------------------------------------------------------------- 1 | ActiveRecord::Migration.verbose = false 2 | 3 | ActiveRecord::Schema.define do 4 | create_table :posts do |t| 5 | t.boolean :published 6 | end 7 | 8 | create_table :post_translations do |t| 9 | t.string :locale 10 | t.references :post 11 | t.string :title 12 | end 13 | 14 | create_table :versions do |t| 15 | t.string :item_type, null: false 16 | t.integer :item_id, null: false 17 | t.string :event, null: false 18 | t.string :whodunnit 19 | t.text :object 20 | t.string :locale 21 | t.datetime :created_at 22 | end 23 | 24 | add_index :versions, [:item_type, :item_id], name: "index_versions_on_item_type_and_item_id" 25 | end 26 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 42 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: stale 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /test/globalize-versioning/options_test.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../test_helper', __FILE__) 2 | 3 | class OptionsTest < MiniTest::Spec 4 | def setup 5 | @options_post_class = Class.new(OptionsPost) 6 | end 7 | 8 | it 'passes options to versioning gem' do 9 | Module.const_set('PostClass', @options_post_class) 10 | 11 | # options passed to paper_trail: :on => :update 12 | @options_post_class.class_eval do 13 | attribute :title 14 | translates :title, :versioning => { :gem => :paper_trail, :options => { :on => [ :update ] } } 15 | end 16 | 17 | post = @options_post_class.create!(:title => 'title v1') 18 | assert_equal 0, post.translation.versions.length 19 | post.update! :title => 'title v2' 20 | assert_equal 1, post.translation.versions.length 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/globalize/versioning.rb: -------------------------------------------------------------------------------- 1 | require 'globalize' 2 | 3 | module Globalize::Versioning 4 | autoload :PaperTrail, 'globalize/versioning/paper_trail' 5 | autoload :InstanceMethods, 'globalize/versioning/instance_methods' 6 | end 7 | 8 | Globalize::ActiveRecord::ActMacro.module_eval do 9 | def setup_translates_with_versioning!(options) 10 | setup_translates_without_versioning!(options) 11 | 12 | if options[:versioning] 13 | include Globalize::Versioning::InstanceMethods 14 | 15 | # hard-coded for now 16 | class_attribute :versioning_gem, :instance_accessor => false 17 | self.versioning_gem = :paper_trail 18 | 19 | ::ActiveRecord::Base.extend(Globalize::Versioning::PaperTrail) 20 | if options[:versioning].is_a?(Hash) 21 | translation_class.has_paper_trail(options[:versioning][:options]) 22 | else 23 | translation_class.has_paper_trail 24 | end 25 | end 26 | end 27 | 28 | alias_method :setup_translates_without_versioning!, :setup_translates! 29 | alias_method :setup_translates!, :setup_translates_with_versioning! 30 | end 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2013 Philip Arndt, Chris Salzberg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /globalize-versioning.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require File.expand_path('../lib/globalize/versioning/version.rb', __FILE__) 3 | 4 | Gem::Specification.new do |s| 5 | s.name = 'globalize-versioning' 6 | s.version = Globalize::Versioning::VERSION 7 | s.authors = ['Philip Arndt', 'Chris Salzberg'] 8 | s.email = 'nobody@globalize-rails.org' 9 | s.homepage = 'http://github.com/globalize/globalize-versioning' 10 | s.summary = 'Adapter for using versioning gems with Globalize' 11 | s.description = "Provides support for using versioning gems such as PaperTrail with Globalize." 12 | s.license = "MIT" 13 | 14 | s.files = Dir['{lib/**/*,[A-Z]*}'] 15 | s.platform = Gem::Platform::RUBY 16 | s.require_path = 'lib' 17 | 18 | s.add_dependency 'activerecord', '>= 4.2.0', '< 8.0' 19 | s.add_dependency 'activemodel', '>= 4.2.0', '< 8.0' 20 | s.add_dependency 'globalize', '>= 5.1.0', '< 7' 21 | s.add_dependency 'paper_trail', '>= 8', '< 16' 22 | 23 | s.add_development_dependency 'database_cleaner', '>= 1.2.0' 24 | s.add_development_dependency 'minitest' 25 | s.add_development_dependency 'sqlite3' 26 | s.add_development_dependency 'rdoc' 27 | s.add_development_dependency 'rake' 28 | end 29 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' 7 | pull_request: 8 | jobs: 9 | test: 10 | strategy: 11 | matrix: 12 | gemfile: [ '7.0.0', '6.1.3.1', '6.0.3.6', '5.2.5', '5.1.7', '4.2.11.3' ] 13 | ruby: [ '3.1', '3.0', '2.7' ] 14 | exclude: 15 | - ruby: '3.1' 16 | gemfile: '5.2.5' 17 | - ruby: '3.1' 18 | gemfile: '5.1.7' 19 | - ruby: '3.1' 20 | gemfile: '4.2.11.3' 21 | - ruby: '3.0' 22 | gemfile: '5.2.5' 23 | - ruby: '3.0' 24 | gemfile: '5.1.7' 25 | - ruby: '3.0' 26 | gemfile: '4.2.11.3' 27 | - ruby: '2.7' 28 | gemfile: '4.2.11.3' 29 | fail-fast: false 30 | runs-on: ubuntu-latest 31 | name: ${{ matrix.ruby }} rails-${{ matrix.gemfile }} 32 | steps: 33 | - uses: actions/checkout@v3 34 | - uses: ruby/setup-ruby@v1 35 | with: 36 | ruby-version: ${{ matrix.ruby }} 37 | bundler-cache: true 38 | - run: bundle exec rake test 39 | 40 | env: 41 | BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.gemfile }}.gemfile 42 | BUNDLE_JOBS: 4 43 | BUNDLE_PATH: vendor/bundle 44 | CI: true 45 | RAILS_ENV: test 46 | -------------------------------------------------------------------------------- /lib/globalize/versioning/paper_trail.rb: -------------------------------------------------------------------------------- 1 | require 'paper_trail' 2 | 3 | module Globalize 4 | module Versioning 5 | module PaperTrail 6 | # At present this isn't used but we may use something similar in paper trail 7 | # shortly, so leaving it around to reference easily. 8 | #def versioned_columns 9 | #super + self.class.translated_attribute_names 10 | #end 11 | end 12 | end 13 | end 14 | 15 | ActiveRecord::Base.class_eval do 16 | class << self 17 | def has_paper_trail_with_globalize(*args) 18 | has_paper_trail_without_globalize(*args) 19 | include Globalize::Versioning::PaperTrail 20 | end 21 | alias_method :has_paper_trail_without_globalize, :has_paper_trail 22 | alias_method :has_paper_trail, :has_paper_trail_with_globalize 23 | end 24 | end 25 | 26 | # to handle different versions of paper_trail 27 | version_class = PaperTrail::VERSION.is_a?(String) ? Version : PaperTrail::Version 28 | 29 | version_class.class_eval do 30 | 31 | before_save do |version| 32 | version.locale = Globalize.locale.to_s 33 | end 34 | 35 | def self.for_this_locale 36 | where :locale => Globalize.locale.to_s 37 | end 38 | 39 | def sibling_versions_with_locales 40 | sibling_versions_without_locales.for_this_locale 41 | end 42 | alias_method :sibling_versions_without_locales, :sibling_versions 43 | alias_method :sibling_versions, :sibling_versions_with_locales 44 | end 45 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Globalize Versioning [![Build Status](https://travis-ci.org/globalize/globalize-versioning.png?branch=master)](https://travis-ci.org/globalize/globalize-versioning) 2 | 3 | ## Introduction 4 | 5 | `globalize-versioning` provides an interface between globalize and versioning gems such as 6 | [PaperTrail](https://github.com/airblade/paper_trail). 7 | 8 | At the moment, only `paper_trail` is supported, but support for other versioning gems is 9 | planned for the future. Pull requests are always welcome. 10 | 11 | ## Installation 12 | 13 | ````ruby 14 | gem install globalize-versioning 15 | ```` 16 | 17 | When using bundler, add this line to your `Gemfile`: 18 | 19 | ```ruby 20 | gem 'globalize-versioning' 21 | ``` 22 | 23 | ## Usage 24 | 25 | To add versioning 26 | support to your model, just add the `:versioning` option to your 27 | call to translates with the name of the versioning gem as its value. 28 | For example: 29 | 30 | ```ruby 31 | translates :title, :content, :published, :published_at, :versioning => :paper_trail 32 | ``` 33 | 34 | You will also need to have already generated the versions table that `paper_trail` 35 | expects. See the paper_trail README for more details. 36 | 37 | To pass options to the versioning gem, replace the gem name with a hash, and include 38 | the options as the value of the `:options` key: 39 | 40 | ```ruby 41 | translates :title, :content, :published, :published_at, :versioning => { :gem => :paper_trail, :options => { :on => [ :update ] } } 42 | ``` 43 | 44 | To access versions of a translated model, use the format: `post.translation.versions`. 45 | Earlier versions of the globalize versioning support delegated `version` and `versions` 46 | to the model translation (so you could access them with just `post.versions`), but 47 | this causes problems if versioning is used on non-translated attributes, and has thus been removed. 48 | 49 | ## Adding globalize versioning to previously versioned models 50 | 51 | If you are adding globalize to any previously versioned models, please note 52 | that you will need to add a new `locale` column to your versioning table. 53 | 54 | ## Other gotchas 55 | 56 | Please see the tests in `test/globalize-versioning/` for more details. 57 | 58 | ## License 59 | 60 | See [LICENSE](LICENSE) for details. 61 | -------------------------------------------------------------------------------- /test/globalize-versioning/versioning_test.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../test_helper', __FILE__) 2 | 3 | class VersioningTest < MiniTest::Spec 4 | 5 | it "creates only one version when created" do 6 | post = Post.create!(:title => 'title v1') 7 | assert_equal 1, post.translation.versions.length 8 | end 9 | 10 | it "versions are scoped to the current Globalize locale" do 11 | post = Post.create!(:title => 'title v1') 12 | 13 | post.update!(:title => 'title v2') 14 | # Creates a 'created' version, and the update 15 | assert_equal %w[en en], post.translation.versions.map(&:locale) 16 | 17 | Globalize.with_locale(:de) { 18 | post.update!(:title => 'Titel v1') 19 | assert_equal %w[de], post.translation.versions.map(&:locale) 20 | } 21 | 22 | post.translation.versions.reset # hrmmm. 23 | assert_equal %w[en en], post.translation.versions.map(&:locale) 24 | end 25 | 26 | it "only reverts changes to the current locale when reverting to an earlier version" do 27 | post = Post.create!(:title => 'title v1') 28 | post.update!(:title => 'title v2') 29 | post.update!(:title => 'Titel v1', :locale => :de) 30 | post.update!(:title => 'title v3') 31 | 32 | # Roll back 2 versions in default locale 33 | post.rollback 34 | post.rollback 35 | 36 | assert_equal 'title v1', post.title(:en) 37 | assert_equal 'Titel v1', post.title(:de) 38 | end 39 | 40 | it "only reverts in the current locale" do 41 | post = Post.create!(:title => 'title v1') 42 | 43 | with_locale(:en) do 44 | post.update!(:title => 'updated title in English') 45 | end 46 | 47 | with_locale(:de) do 48 | post.update!(:title => 'updated title in German') 49 | end 50 | 51 | with_locale(:en) do 52 | post.update!(:title => 'updated title in English, v2') 53 | end 54 | 55 | with_locale(:de) do 56 | post.update!(:title => 'updated title in German, v2') 57 | end 58 | 59 | with_locale(:en) do 60 | post.rollback 61 | assert_equal 'updated title in English', post.title 62 | 63 | post.rollback 64 | assert_equal 'title v1', post.title 65 | end 66 | 67 | with_locale(:de) do 68 | post.rollback 69 | assert_equal 'updated title in German', post.title 70 | end 71 | 72 | with_locale(:en) do 73 | assert_equal 'title v1', post.title 74 | end 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require 'bundler/setup' 2 | require 'fileutils' 3 | require 'logger' 4 | 5 | Bundler.require(:default, :test) 6 | require 'database_cleaner' 7 | 8 | log = '/tmp/globalize3_test.log' 9 | FileUtils.touch(log) unless File.exists?(log) 10 | ActiveRecord::Base.logger = Logger.new(log) 11 | ActiveRecord::LogSubscriber.attach_to(:active_record) 12 | ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:') 13 | 14 | $:.unshift File.expand_path('../../lib', __FILE__) 15 | require 'globalize' 16 | require 'erb' 17 | 18 | require File.expand_path('../data/schema', __FILE__) 19 | require File.expand_path('../data/models', __FILE__) 20 | 21 | DatabaseCleaner.strategy = :truncation 22 | 23 | require 'minitest/autorun' 24 | require 'minitest/spec' 25 | MiniTest::Spec.class_eval do 26 | def setup 27 | I18n.locale = I18n.default_locale = :en 28 | Globalize.locale = nil 29 | DatabaseCleaner.start 30 | end 31 | 32 | def teardown 33 | DatabaseCleaner.clean 34 | end 35 | 36 | def with_locale(*args, &block) 37 | Globalize.with_locale(*args, &block) 38 | end 39 | 40 | def with_fallbacks 41 | previous = I18n.backend 42 | I18n.backend = BackendWithFallbacks.new 43 | I18n.pretend_fallbacks 44 | return yield 45 | ensure 46 | I18n.hide_fallbacks 47 | I18n.backend = previous 48 | end 49 | 50 | def assert_belongs_to(model, other) 51 | assert_association(model, :belongs_to, other) 52 | end 53 | 54 | def assert_has_many(model, other) 55 | assert_association(model, :has_many, other) 56 | end 57 | 58 | def assert_association(model, type, other) 59 | assert model.reflect_on_all_associations(type).any? { |a| a.name == other } 60 | end 61 | 62 | def assert_translated(record, locale, attributes, translations) 63 | assert_equal Array.wrap(translations), Array.wrap(attributes).map { |name| record.send(name, locale) } 64 | end 65 | end 66 | 67 | ActiveRecord::Base.class_eval do 68 | class << self 69 | def index_exists?(index_name) 70 | connection.indexes(table_name).any? { |index| index.name == index_name.to_s } 71 | end 72 | 73 | def index_exists_on?(column_name) 74 | connection.indexes(table_name).any? { |index| index.columns == [column_name.to_s] } 75 | end 76 | end 77 | end 78 | 79 | class BackendWithFallbacks < I18n::Backend::Simple 80 | include I18n::Backend::Fallbacks 81 | end 82 | 83 | meta = class << I18n; self; end 84 | meta.class_eval do 85 | alias_method(:alternatives, :fallbacks) 86 | 87 | def pretend_fallbacks 88 | class << I18n; self; end.send(:alias_method, :fallbacks, :alternatives) 89 | end 90 | 91 | def hide_fallbacks 92 | class << I18n; self; end.send(:remove_method, :fallbacks) 93 | end 94 | end 95 | 96 | I18n.hide_fallbacks 97 | --------------------------------------------------------------------------------