Skip to content

Commit

Permalink
Merge branch 'master' into pr-51-thread-safety-fix
Browse files Browse the repository at this point in the history
* master: (45 commits)
  Add regression test for #378
  Bump to 0.8.6
  Add fallback_in_progress to RESERVED_KEYS list
  Bump to 0.8.5
  Fixes #369 thread issue when calling translate with fallbacks
  Remove gemfiles/Gemfile.*.lock from the repo
  Improve error message for missing pluralization key
  Bump to 0.8.4
  Revert "Don't allow nil to be submitted as a key to i18n.translate()"
  Bump to 0.8.3
  Update Changelog
  Handle false as a key correctly
  Bump Gemfiles
  Bump to 0.8.2
  Add Gemfile.lock for each Rails version
  Bump to 0.8.1
  Fix transliteration to default replacement char
  Docs: Add 0.8.0 to changelog
  No need to skip ruby 2.4+ x rails 4 now
  CI against newest stable rubies for each minor version
  ...
  • Loading branch information
radar committed Oct 1, 2017
2 parents 5480dd3 + 6ab51c7 commit 358249b
Show file tree
Hide file tree
Showing 30 changed files with 154 additions and 316 deletions.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,21 @@
## What I tried to do

* Fill this out!

## What I expected to happen

* Fill this out!

## What actually happened

* Fill this out!

## Versions of i18n, rails, and anything else you think is neccessary

* Fill this out!

----

Bonus points for providing an application or a small code example which reproduces the issue.

Thanks! :heart:
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ vendor/**/*
pkg
.bundle
.rvmrc
Gemfile.lock
18 changes: 6 additions & 12 deletions .travis.yml
Expand Up @@ -4,9 +4,10 @@ before_install:
rvm:
- 1.9.3
- 2.0.0
- 2.1.8
- 2.2.4
- 2.3.1
- 2.1.10
- 2.2.6
- 2.3.3
- 2.4.0
- ruby-head
- rbx
- jruby
Expand All @@ -27,22 +28,15 @@ matrix:
gemfile: gemfiles/Gemfile.rails-master
- rvm: 2.0.0
gemfile: gemfiles/Gemfile.rails-master
- rvm: 2.1.8
- rvm: 2.1.10
gemfile: gemfiles/Gemfile.rails-master
- rvm: 1.9.3
gemfile: gemfiles/Gemfile.rails-5.0.x
- rvm: 2.0.0
gemfile: gemfiles/Gemfile.rails-5.0.x
- rvm: 2.1.8
- rvm: 2.1.10
gemfile: gemfiles/Gemfile.rails-5.0.x
# activesupport has a dependency on json, which does not build on this version
- rvm: ruby-head
gemfile: gemfiles/Gemfile.rails-4.1.x
# activesupport has a dependency on json, which does not build on this version
- rvm: ruby-head
gemfile: gemfiles/Gemfile.rails-4.2.x
allow_failures:
- rvm: 2.2
- rvm: rbx
- rvm: jruby
fast_finish: true
16 changes: 14 additions & 2 deletions CHANGELOG.md
@@ -1,6 +1,18 @@
# master
# 0.8.3

* `Hash#slice` ignores non existing keys.
See https://github.com/svenfuchs/i18n/releases/tag/v0.8.3

# 0.8.2

See https://github.com/svenfuchs/i18n/releases/tag/v0.8.2

# 0.8.1

See https://github.com/svenfuchs/i18n/releases/tag/v0.8.1

# 0.8.0

See https://github.com/svenfuchs/i18n/releases/tag/v0.8.0

# 0.7.0

Expand Down
30 changes: 0 additions & 30 deletions Gemfile.lock

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -4,6 +4,8 @@

Ruby Internationalization and localization solution.

[See the Rails Guide](http://guides.rubyonrails.org/i18n.html) for an example of its usage. (Note: This library can be used independently from Rails.)

Features:

* translation and localization
Expand Down
32 changes: 0 additions & 32 deletions gemfiles/Gemfile.rails-3.2.x.lock

This file was deleted.

37 changes: 0 additions & 37 deletions gemfiles/Gemfile.rails-4.0.x.lock

This file was deleted.

38 changes: 0 additions & 38 deletions gemfiles/Gemfile.rails-4.1.x.lock

This file was deleted.

38 changes: 0 additions & 38 deletions gemfiles/Gemfile.rails-4.2.x.lock

This file was deleted.

37 changes: 0 additions & 37 deletions gemfiles/Gemfile.rails-5.0.x.lock

This file was deleted.

43 changes: 0 additions & 43 deletions gemfiles/Gemfile.rails-master.lock

This file was deleted.

2 changes: 1 addition & 1 deletion lib/i18n.rb
Expand Up @@ -11,7 +11,7 @@ module I18n
autoload :Locale, 'i18n/locale'
autoload :Tests, 'i18n/tests'

RESERVED_KEYS = [:scope, :default, :separator, :resolve, :object, :fallback, :format, :cascade, :throw, :raise, :deep_interpolation]
RESERVED_KEYS = [:scope, :default, :separator, :resolve, :object, :fallback, :fallback_in_progress, :format, :cascade, :throw, :raise, :deep_interpolation]
RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/

module Base
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/backend/base.rb
Expand Up @@ -23,7 +23,7 @@ def store_translations(locale, data, options = {})

def translate(locale, key, options = {})
raise InvalidLocale.new(locale) unless locale
entry = key && lookup(locale, key, options[:scope], options)
entry = lookup(locale, key, options[:scope], options) unless key.nil?

if entry.nil? && options.key?(:default)
entry = default(locale, key, options[:default], options)
Expand Down Expand Up @@ -136,14 +136,14 @@ def resolve(locale, object, subject, options = {})
# - It will pick the :other subkey otherwise.
# - It will pick the :zero subkey in the special case where count is
# equal to 0 and there is a :zero subkey present. This behaviour is
# not stand with regards to the CLDR pluralization rules.
# not standard with regards to the CLDR pluralization rules.
# Other backends can implement more flexible or complex pluralization rules.
def pluralize(locale, entry, count)
return entry unless entry.is_a?(Hash) && count

key = :zero if count == 0 && entry.has_key?(:zero)
key ||= count == 1 ? :one : :other
raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key)
entry[key]
end

Expand Down

0 comments on commit 358249b

Please sign in to comment.