mini_i18n 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 748e42499af526adff60a56957acc33011de4885
4
- data.tar.gz: 33139b385903ab20af789f9bd9ad03bc4a87b519
3
+ metadata.gz: aaf36c6e857bd3a2b63925d82b9757f6f550c3fc
4
+ data.tar.gz: ea8e88fdbe0299a90367eb1b92f92e04b2089ab1
5
5
  SHA512:
6
- metadata.gz: 2cf99b8fb0fc6f67230c0a5fdcaa7742b23f1a0323afdeab870a090283ce193e060552a3b5f67d0c68dde7a5ede361a36b5f8f33d6cd267e5d3ae5c7497a2284
7
- data.tar.gz: 6a4405281d8ec7086392d650b22a7c714fc906178419b4344850935065ebf07b04e14db7b66aa142df87eba8c3c71e54e24fa093ce7ad23d49d2ae60447cc5c8
6
+ metadata.gz: 68d29e18fb17542eb1801d95c743625b5732bd050123e5e1dd17c0db5fcb076aa4f32aed00f8b40243d0076461675ad8d727d92fc136f09c64f4dbb789c23527
7
+ data.tar.gz: db0a08f461d7204aad83e88bebf9ca29935acb9b4434fc228d30b341c7f2ddc9b2cea483a5c15f434a302f1b96a2618a377e60858997e7c034f73a4e0abed238
data/lib/mini_i18n.rb CHANGED
@@ -62,6 +62,8 @@ module MiniI18n
62
62
 
63
63
  def translate(key, options = {})
64
64
  return if key.empty? || translations.empty?
65
+ return multiple_translate(key, options) if key.is_a?(Array)
66
+ return multiple_locales(key, options) if options[:locale].is_a?(Array)
65
67
 
66
68
  _locale = available_locale?(options[:locale]) || locale
67
69
  scope = options[:scope]
@@ -145,5 +147,17 @@ module MiniI18n
145
147
 
146
148
  result
147
149
  end
150
+
151
+ def multiple_translate(keys, options)
152
+ keys.map do |key|
153
+ t(key, options)
154
+ end
155
+ end
156
+
157
+ def multiple_locales(key, options)
158
+ options[:locale].map do |_locale|
159
+ t(key, options.merge(locale: _locale))
160
+ end
161
+ end
148
162
  end
149
163
  end
@@ -1,3 +1,3 @@
1
1
  module MiniI18n
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -57,11 +57,21 @@ RSpec.describe MiniI18n do
57
57
  expect(MiniI18n.t('second_level.hello')).to eq 'hello 2'
58
58
  end
59
59
 
60
+ it "multiple keys" do
61
+ expect(MiniI18n.t([:hello, :bye])).to eq ['hello', 'bye']
62
+ expect(MiniI18n.t([:hello, :bye], locale: :fr)).to eq ['bonjour', 'au revoir']
63
+ end
64
+
60
65
  it "locale" do
61
66
  expect(MiniI18n.t('hello', locale: :fr)).to eq 'bonjour'
62
67
  expect(MiniI18n.t('hello', locale: :es)).to eq 'hola'
63
68
  end
64
69
 
70
+ it "multiple locales" do
71
+ expect(MiniI18n.t(:hello, locale: [:en, :fr, :es])).to eq ['hello', 'bonjour', 'hola']
72
+ expect(MiniI18n.t(:hello_interpolation, name: 'world', locale: [:en])).to eq ['hello world']
73
+ end
74
+
65
75
  it "scope" do
66
76
  expect(MiniI18n.t('hello', scope: :second_level)).to eq 'hello 2'
67
77
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'simplecov'
2
+ SimpleCov.start { add_filter 'spec/' }
3
+
1
4
  require "mini_i18n"
2
5
 
3
6
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - markets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-13 00:00:00.000000000 Z
11
+ date: 2018-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Minimalistic I18n library for Ruby. It supports localization, pluralization,
70
84
  interpolations, fallbacks, nested keys and more.
71
85
  email: