Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support I18n 1.10.0 #9

Merged
merged 1 commit into from Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# CHANGELOG

- Support i18n 1.10.0
- Drop support for Ruby < 2.7

## v1.1.0

- Remove upper bound on i18n dependency
5 changes: 3 additions & 2 deletions i18n-backend-side_by_side.gemspec
Expand Up @@ -16,9 +16,10 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 2.0.0'
spec.required_ruby_version = '>= 2.7.0'

spec.add_development_dependency 'rake'
spec.add_development_dependency 'minitest'
spec.add_dependency 'i18n', '>= 1.3.0'
spec.add_dependency 'i18n', '>= 1.10.0'
spec.add_dependency 'activesupport', '>= 6.0.0'
end
10 changes: 4 additions & 6 deletions lib/i18n/backend/side_by_side.rb
@@ -1,10 +1,8 @@
require 'i18n'
require 'i18n/core_ext/hash'
require 'active_support/core_ext/hash/keys'

module I18n
module Backend
using HashRefinements

class SideBySide < Simple
VERSION = File.read(File.expand_path('../../../../VERSION', __FILE__))
LOCALE_PREFIX = '_'
Expand All @@ -14,13 +12,13 @@ class SideBySide < Simple
def load_file(filename)
type = File.extname(filename).tr('.', '').downcase
raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}", true)
data = send(:"load_#{type}", filename)
data = send(:"load_#{type}", filename).first
unless data.is_a?(Hash)
raise InvalidLocaleData.new(filename, 'expects it to return a hash, but does not')
end

if data.first.first == LOCALE_PREFIX
_process([], data[LOCALE_PREFIX].deep_symbolize_keys)
if data.first.first.to_s == LOCALE_PREFIX
_process([], data.deep_symbolize_keys[LOCALE_PREFIX.to_sym])
else
data.each { |locale, d| store_translations(locale, d || {}) }
end
Expand Down