r18n-rails-api 3.0.5 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/ChangeLog.md +382 -0
 - data/README.md +16 -25
 - data/lib/r18n-rails-api/backend.rb +24 -27
 - data/lib/r18n-rails-api/filters.rb +5 -7
 - data/lib/r18n-rails-api/loader.rb +15 -13
 - data/lib/r18n-rails-api/rails_plural.rb +7 -7
 - data/lib/r18n-rails-api/version.rb +9 -0
 - metadata +173 -50
 - data/.rspec +0 -1
 - data/Rakefile +0 -13
 - data/r18n-rails-api.gemspec +0 -33
 - data/spec/backend_spec.rb +0 -125
 - data/spec/data/general/en.yml +0 -21
 - data/spec/data/general/ru.yml +0 -4
 - data/spec/data/other/en.yml +0 -2
 - data/spec/data/other/ru.yml +0 -2
 - data/spec/data/pl/ru.yml +0 -6
 - data/spec/data/simple/de-CH.yml +0 -2
 - data/spec/data/simple/en.yml +0 -6
 - data/spec/data/simple/ru.rb +0 -3
 - data/spec/data/simple/russian.yml +0 -2
 - data/spec/filters_spec.rb +0 -39
 - data/spec/loader_spec.rb +0 -60
 - data/spec/spec_helper.rb +0 -18
 
    
        data/.rspec
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --format documentation --colour --warnings --require spec_helper
         
     | 
    
        data/Rakefile
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'bundler/setup'
         
     | 
| 
       4 
     | 
    
         
            -
            Bundler::GemHelper.install_tasks
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            require 'rspec/core/rake_task'
         
     | 
| 
       7 
     | 
    
         
            -
            RSpec::Core::RakeTask.new
         
     | 
| 
       8 
     | 
    
         
            -
            task default: :spec
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            task :clobber_package do
         
     | 
| 
       11 
     | 
    
         
            -
              rm_rf 'pkg'
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
       13 
     | 
    
         
            -
            task clobber: [:clobber_package]
         
     | 
    
        data/r18n-rails-api.gemspec
    DELETED
    
    | 
         @@ -1,33 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require_relative '../r18n-core/lib/r18n-core/version'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            Gem::Specification.new do |s|
         
     | 
| 
       6 
     | 
    
         
            -
              s.platform = Gem::Platform::RUBY
         
     | 
| 
       7 
     | 
    
         
            -
              s.name     = 'r18n-rails-api'
         
     | 
| 
       8 
     | 
    
         
            -
              s.version  = R18n::VERSION.dup
         
     | 
| 
       9 
     | 
    
         
            -
              s.date     = Time.now.strftime('%Y-%m-%d')
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              s.summary     = 'Rails I18n compatibility for R18n'
         
     | 
| 
       12 
     | 
    
         
            -
              s.description = <<-DESC
         
     | 
| 
       13 
     | 
    
         
            -
                R18n backend for Rails I18n and R18n filters and loader to support Rails
         
     | 
| 
       14 
     | 
    
         
            -
                translation format.
         
     | 
| 
       15 
     | 
    
         
            -
                R18n has nice Ruby-style syntax, filters, flexible locales, custom loaders,
         
     | 
| 
       16 
     | 
    
         
            -
                translation support for any classes, time and number localization, several
         
     | 
| 
       17 
     | 
    
         
            -
                user language support, agnostic core package with out-of-box support for
         
     | 
| 
       18 
     | 
    
         
            -
                Rails, Sinatra and desktop applications.
         
     | 
| 
       19 
     | 
    
         
            -
              DESC
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              s.files            = `git ls-files`.split("\n")
         
     | 
| 
       22 
     | 
    
         
            -
              s.test_files       = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
       23 
     | 
    
         
            -
              s.extra_rdoc_files = ['README.md', 'LICENSE']
         
     | 
| 
       24 
     | 
    
         
            -
              s.require_path     = 'lib'
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              s.author   = 'Andrey Sitnik'
         
     | 
| 
       27 
     | 
    
         
            -
              s.email    = 'andrey@sitnik.ru'
         
     | 
| 
       28 
     | 
    
         
            -
              s.homepage = 'https://github.com/ai/r18n/tree/master/r18n-rails-api'
         
     | 
| 
       29 
     | 
    
         
            -
              s.license  = 'LGPL-3'
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              s.add_dependency 'i18n'
         
     | 
| 
       32 
     | 
    
         
            -
              s.add_dependency 'r18n-core', "= #{R18n::VERSION}"
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/backend_spec.rb
    DELETED
    
    | 
         @@ -1,125 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe R18n::Backend do
         
     | 
| 
       4 
     | 
    
         
            -
              before do
         
     | 
| 
       5 
     | 
    
         
            -
                I18n.load_path = [GENERAL]
         
     | 
| 
       6 
     | 
    
         
            -
                I18n.backend = R18n::Backend.new
         
     | 
| 
       7 
     | 
    
         
            -
                R18n.default_places = R18n::Loader::Rails.new
         
     | 
| 
       8 
     | 
    
         
            -
                R18n.set('en')
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              it 'returns available locales' do
         
     | 
| 
       12 
     | 
    
         
            -
                expect(I18n.available_locales).to match_array(%i[en ru])
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              it 'localizes objects' do
         
     | 
| 
       16 
     | 
    
         
            -
                time = Time.at(0).utc
         
     | 
| 
       17 
     | 
    
         
            -
                date = Date.parse('1970-01-01')
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                expect(I18n.l(time)).to eq 'Thu, 01 Jan 1970 00:00:00 +0000'
         
     | 
| 
       20 
     | 
    
         
            -
                expect(I18n.l(date)).to eq '1970-01-01'
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                expect(I18n.l(time, format: :short)).to eq '01 Jan 00:00'
         
     | 
| 
       23 
     | 
    
         
            -
                expect(I18n.l(time, format: :full)).to  eq '1st of January, 1970 00:00'
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                expect(I18n.l(-5000.5)).to eq '−5,000.5'
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              it 'translates by key and scope' do
         
     | 
| 
       29 
     | 
    
         
            -
                expect(I18n.t('in.another.level')).to            eq 'Hierarchical'
         
     | 
| 
       30 
     | 
    
         
            -
                expect(I18n.t(:level, scope: 'in.another')).to   eq 'Hierarchical'
         
     | 
| 
       31 
     | 
    
         
            -
                expect(I18n.t(:'another.level', scope: 'in')).to eq 'Hierarchical'
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              it 'uses pluralization and variables' do
         
     | 
| 
       35 
     | 
    
         
            -
                expect(I18n.t('users', count: 0)).to eq '0 users'
         
     | 
| 
       36 
     | 
    
         
            -
                expect(I18n.t('users', count: 1)).to eq '1 user'
         
     | 
| 
       37 
     | 
    
         
            -
                expect(I18n.t('users', count: 5)).to eq '5 users'
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
              it 'uses another separator' do
         
     | 
| 
       41 
     | 
    
         
            -
                expect(I18n.t('in/another/level', separator: '/')).to eq 'Hierarchical'
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              it 'translates array' do
         
     | 
| 
       45 
     | 
    
         
            -
                expect(I18n.t(['in.another.level', 'in.default'])).to eq(
         
     | 
| 
       46 
     | 
    
         
            -
                  %w[Hierarchical Default]
         
     | 
| 
       47 
     | 
    
         
            -
                )
         
     | 
| 
       48 
     | 
    
         
            -
              end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
              it 'uses default value' do
         
     | 
| 
       51 
     | 
    
         
            -
                expect(I18n.t(:missed, default: 'Default')).to                 eq 'Default'
         
     | 
| 
       52 
     | 
    
         
            -
                expect(I18n.t(:missed, default: :default, scope: :in)).to      eq 'Default'
         
     | 
| 
       53 
     | 
    
         
            -
                expect(I18n.t(:missed, default: %i[also_no in.default])).to    eq 'Default'
         
     | 
| 
       54 
     | 
    
         
            -
                expect(I18n.t(:missed, default: proc { |key| key.to_s })).to   eq 'missed'
         
     | 
| 
       55 
     | 
    
         
            -
              end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
              it 'raises error on no translation' do
         
     | 
| 
       58 
     | 
    
         
            -
                expect(lambda {
         
     | 
| 
       59 
     | 
    
         
            -
                  I18n.backend.translate(:en, :missed)
         
     | 
| 
       60 
     | 
    
         
            -
                }).to raise_error(::I18n::MissingTranslationData)
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                expect(lambda {
         
     | 
| 
       63 
     | 
    
         
            -
                  I18n.t(:missed)
         
     | 
| 
       64 
     | 
    
         
            -
                }).to raise_error(::I18n::MissingTranslationData)
         
     | 
| 
       65 
     | 
    
         
            -
              end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
              it 'reloads translations' do
         
     | 
| 
       68 
     | 
    
         
            -
                expect(-> { I18n.t(:other) }).to raise_error(::I18n::MissingTranslationData)
         
     | 
| 
       69 
     | 
    
         
            -
                I18n.load_path << OTHER
         
     | 
| 
       70 
     | 
    
         
            -
                I18n.reload!
         
     | 
| 
       71 
     | 
    
         
            -
                expect(I18n.t(:other)).to eq 'Other'
         
     | 
| 
       72 
     | 
    
         
            -
              end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
              it 'returns plain classes' do
         
     | 
| 
       75 
     | 
    
         
            -
                expect(I18n.t('in.another.level').class).to eq ActiveSupport::SafeBuffer
         
     | 
| 
       76 
     | 
    
         
            -
                expect(I18n.t('in.another').class).to eq Hash
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
              it 'returns correct unpluralized hash' do
         
     | 
| 
       80 
     | 
    
         
            -
                expect(I18n.t('users')).to eq(one: '1 user', other: '%{count} users')
         
     | 
| 
       81 
     | 
    
         
            -
              end
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
              it 'corrects detect untranslated, whem path is deeper than string' do
         
     | 
| 
       84 
     | 
    
         
            -
                expect(lambda {
         
     | 
| 
       85 
     | 
    
         
            -
                  I18n.t('in.another.level.deeper')
         
     | 
| 
       86 
     | 
    
         
            -
                }).to raise_error(::I18n::MissingTranslationData)
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                expect(lambda {
         
     | 
| 
       89 
     | 
    
         
            -
                  I18n.t('in.another.level.go.deeper')
         
     | 
| 
       90 
     | 
    
         
            -
                }).to raise_error(::I18n::MissingTranslationData)
         
     | 
| 
       91 
     | 
    
         
            -
              end
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
              it "doesn't call String methods" do
         
     | 
| 
       94 
     | 
    
         
            -
                expect(I18n.t('in.another').class).to eq Hash
         
     | 
| 
       95 
     | 
    
         
            -
              end
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
              it "doesn't call object methods" do
         
     | 
| 
       98 
     | 
    
         
            -
                expect(lambda {
         
     | 
| 
       99 
     | 
    
         
            -
                  I18n.t('in.another.level.to_sym')
         
     | 
| 
       100 
     | 
    
         
            -
                }).to raise_error(::I18n::MissingTranslationData)
         
     | 
| 
       101 
     | 
    
         
            -
              end
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
              it 'works deeper pluralization' do
         
     | 
| 
       104 
     | 
    
         
            -
                expect(I18n.t('users.other', count: 5)).to eq '5 users'
         
     | 
| 
       105 
     | 
    
         
            -
              end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
              it 'returns hash with symbols keys' do
         
     | 
| 
       108 
     | 
    
         
            -
                expect(I18n.t('in')).to eq(
         
     | 
| 
       109 
     | 
    
         
            -
                  another: { level: 'Hierarchical' },
         
     | 
| 
       110 
     | 
    
         
            -
                  default: 'Default'
         
     | 
| 
       111 
     | 
    
         
            -
                )
         
     | 
| 
       112 
     | 
    
         
            -
              end
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
              it 'changes locale in place' do
         
     | 
| 
       115 
     | 
    
         
            -
                I18n.load_path << PL
         
     | 
| 
       116 
     | 
    
         
            -
                expect(I18n.t('users', count: 5)).to eq '5 users'
         
     | 
| 
       117 
     | 
    
         
            -
                expect(I18n.t('users', count: 5, locale: :ru)).to eq 'Много'
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                expect(I18n.l(Date.parse('1970-01-01'), locale: :ru)).to eq '01.01.1970'
         
     | 
| 
       120 
     | 
    
         
            -
              end
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
              it 'has transliterate method' do
         
     | 
| 
       123 
     | 
    
         
            -
                expect(I18n.transliterate('café')).to eq 'cafe'
         
     | 
| 
       124 
     | 
    
         
            -
              end
         
     | 
| 
       125 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/data/general/en.yml
    DELETED
    
    | 
         @@ -1,21 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            en:
         
     | 
| 
       2 
     | 
    
         
            -
              date:
         
     | 
| 
       3 
     | 
    
         
            -
                formats:
         
     | 
| 
       4 
     | 
    
         
            -
                  default: "%Y-%m-%d"
         
     | 
| 
       5 
     | 
    
         
            -
                  short: "%b %d"
         
     | 
| 
       6 
     | 
    
         
            -
                  long: "%B %d, %Y"
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              time:
         
     | 
| 
       9 
     | 
    
         
            -
                formats:
         
     | 
| 
       10 
     | 
    
         
            -
                  default: "%a, %d %b %Y %H:%M:%S %z"
         
     | 
| 
       11 
     | 
    
         
            -
                  short: "%d %b %H:%M"
         
     | 
| 
       12 
     | 
    
         
            -
                  long: "%B %d, %Y %H:%M"
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              in:
         
     | 
| 
       15 
     | 
    
         
            -
                another:
         
     | 
| 
       16 
     | 
    
         
            -
                  level: Hierarchical
         
     | 
| 
       17 
     | 
    
         
            -
                default: Default
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              users:
         
     | 
| 
       20 
     | 
    
         
            -
                one: 1 user
         
     | 
| 
       21 
     | 
    
         
            -
                other: "%{count} users"
         
     | 
    
        data/spec/data/general/ru.yml
    DELETED
    
    
    
        data/spec/data/other/en.yml
    DELETED
    
    
    
        data/spec/data/other/ru.yml
    DELETED
    
    
    
        data/spec/data/pl/ru.yml
    DELETED
    
    
    
        data/spec/data/simple/de-CH.yml
    DELETED
    
    
    
        data/spec/data/simple/en.yml
    DELETED
    
    
    
        data/spec/data/simple/ru.rb
    DELETED
    
    
    
        data/spec/filters_spec.rb
    DELETED
    
    | 
         @@ -1,39 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe 'Rails filters' do
         
     | 
| 
       4 
     | 
    
         
            -
              it 'uses named variables' do
         
     | 
| 
       5 
     | 
    
         
            -
                i18n = R18n::Translation.new(
         
     | 
| 
       6 
     | 
    
         
            -
                  EN, '', locale: EN, translations: { 'echo' => 'Value is %{value}' }
         
     | 
| 
       7 
     | 
    
         
            -
                )
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                expect(i18n.echo(value: 'R18n')).to eq 'Value is R18n'
         
     | 
| 
       10 
     | 
    
         
            -
                expect(i18n.echo(value: -5.5)).to   eq 'Value is −5.5'
         
     | 
| 
       11 
     | 
    
         
            -
                expect(i18n.echo(value: 5000)).to   eq 'Value is 5,000'
         
     | 
| 
       12 
     | 
    
         
            -
                expect(i18n.echo(value: '<b>')).to  eq 'Value is <b>'
         
     | 
| 
       13 
     | 
    
         
            -
                expect(i18n.echo).to eq 'Value is %{value}'
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it 'uses old variables syntax' do
         
     | 
| 
       17 
     | 
    
         
            -
                i18n = R18n::Translation.new(
         
     | 
| 
       18 
     | 
    
         
            -
                  EN, '', locale: EN, translations: { 'echo' => 'Value is {{value}}' }
         
     | 
| 
       19 
     | 
    
         
            -
                )
         
     | 
| 
       20 
     | 
    
         
            -
                expect(i18n.echo(value: 'Old')).to eq 'Value is Old'
         
     | 
| 
       21 
     | 
    
         
            -
              end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
              it 'pluralizes by variable %{count}' do
         
     | 
| 
       24 
     | 
    
         
            -
                i18n = R18n::Translation.new(
         
     | 
| 
       25 
     | 
    
         
            -
                  EN, '', locale: EN, translations: {
         
     | 
| 
       26 
     | 
    
         
            -
                    'users' => R18n::Typed.new(
         
     | 
| 
       27 
     | 
    
         
            -
                      'pl',
         
     | 
| 
       28 
     | 
    
         
            -
                      0 => 'no users',
         
     | 
| 
       29 
     | 
    
         
            -
                      1 => '1 user',
         
     | 
| 
       30 
     | 
    
         
            -
                      'n' => '%{count} users'
         
     | 
| 
       31 
     | 
    
         
            -
                    )
         
     | 
| 
       32 
     | 
    
         
            -
                  }
         
     | 
| 
       33 
     | 
    
         
            -
                )
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                expect(i18n.users(count: 0)).to eq 'no users'
         
     | 
| 
       36 
     | 
    
         
            -
                expect(i18n.users(count: 1)).to eq '1 user'
         
     | 
| 
       37 
     | 
    
         
            -
                expect(i18n.users(count: 5)).to eq '5 users'
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/loader_spec.rb
    DELETED
    
    | 
         @@ -1,60 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe R18n::Loader::Rails do
         
     | 
| 
       4 
     | 
    
         
            -
              before do
         
     | 
| 
       5 
     | 
    
         
            -
                I18n.load_path = [SIMPLE]
         
     | 
| 
       6 
     | 
    
         
            -
                @loader = R18n::Loader::Rails.new
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              it 'returns available locales' do
         
     | 
| 
       10 
     | 
    
         
            -
                expect(@loader.available).to match_array([DECH, EN, RU])
         
     | 
| 
       11 
     | 
    
         
            -
              end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
              it 'loads translation' do
         
     | 
| 
       14 
     | 
    
         
            -
                expect(@loader.load(RU)).to eq('one' => 'Один', 'two' => 'Два')
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              it 'loads translation for dialects' do
         
     | 
| 
       18 
     | 
    
         
            -
                expect(@loader.load(DECH)).to eq('a' => 1)
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              it 'changes pluralization' do
         
     | 
| 
       22 
     | 
    
         
            -
                expect(@loader.load(EN)).to eq(
         
     | 
| 
       23 
     | 
    
         
            -
                  'users' => R18n::Typed.new(
         
     | 
| 
       24 
     | 
    
         
            -
                    'pl',
         
     | 
| 
       25 
     | 
    
         
            -
                    0   => 'Zero',
         
     | 
| 
       26 
     | 
    
         
            -
                    1   => 'One',
         
     | 
| 
       27 
     | 
    
         
            -
                    2   => 'Few',
         
     | 
| 
       28 
     | 
    
         
            -
                    'n' => 'Other'
         
     | 
| 
       29 
     | 
    
         
            -
                  )
         
     | 
| 
       30 
     | 
    
         
            -
                )
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              it 'changes Russian pluralization' do
         
     | 
| 
       34 
     | 
    
         
            -
                I18n.load_path = [PL]
         
     | 
| 
       35 
     | 
    
         
            -
                expect(@loader.load(RU)).to eq(
         
     | 
| 
       36 
     | 
    
         
            -
                  'users' => R18n::Typed.new(
         
     | 
| 
       37 
     | 
    
         
            -
                    'pl',
         
     | 
| 
       38 
     | 
    
         
            -
                    0   => 'Ноль',
         
     | 
| 
       39 
     | 
    
         
            -
                    1   => 'Один',
         
     | 
| 
       40 
     | 
    
         
            -
                    2   => 'Несколько',
         
     | 
| 
       41 
     | 
    
         
            -
                    'n' => 'Много'
         
     | 
| 
       42 
     | 
    
         
            -
                  )
         
     | 
| 
       43 
     | 
    
         
            -
                )
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              it 'reloads translations on load_path changes' do
         
     | 
| 
       47 
     | 
    
         
            -
                I18n.load_path << OTHER
         
     | 
| 
       48 
     | 
    
         
            -
                expect(@loader.load(RU)).to eq(
         
     | 
| 
       49 
     | 
    
         
            -
                  'one'   => 'Один',
         
     | 
| 
       50 
     | 
    
         
            -
                  'two'   => 'Два',
         
     | 
| 
       51 
     | 
    
         
            -
                  'three' => 'Три'
         
     | 
| 
       52 
     | 
    
         
            -
                )
         
     | 
| 
       53 
     | 
    
         
            -
              end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
              it 'changes hash on load_path changes' do
         
     | 
| 
       56 
     | 
    
         
            -
                before = @loader.hash
         
     | 
| 
       57 
     | 
    
         
            -
                I18n.load_path << OTHER
         
     | 
| 
       58 
     | 
    
         
            -
                expect(@loader.hash).not_to eq before
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/spec_helper.rb
    DELETED
    
    | 
         @@ -1,18 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'pp'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'i18n'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'active_support'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            I18n.enforce_available_locales = true
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            require_relative '../lib/r18n-rails-api'
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            EN   = R18n.locale(:en)
         
     | 
| 
       12 
     | 
    
         
            -
            RU   = R18n.locale(:ru)
         
     | 
| 
       13 
     | 
    
         
            -
            DECH = R18n.locale(:'de-CH')
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            GENERAL = Dir.glob(File.join(__dir__, 'data', 'general', '*'))
         
     | 
| 
       16 
     | 
    
         
            -
            SIMPLE  = Dir.glob(File.join(__dir__, 'data', 'simple', '*'))
         
     | 
| 
       17 
     | 
    
         
            -
            OTHER   = Dir.glob(File.join(__dir__, 'data', 'other', '*'))
         
     | 
| 
       18 
     | 
    
         
            -
            PL      = Dir.glob(File.join(__dir__, 'data', 'pl', '*'))
         
     |