i18n-translators-tools 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/i18n-translators-tools.gemspec +5 -2
- data/lib/i18n/backend/translate.rb +31 -14
- data/test/all.rb +1 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 452d7e32ea216d619c8f0d7213a378f8d7caf788
|
4
|
+
data.tar.gz: 3b9958048d471852c791adc90859f810fcaa8e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e110260ed071de344d81cba88dbd2ba59658f577851eb84fec77908478345418c0cfd2b2f0500d03ca896979e1ff852dfe26f1c88ce8f9e5d16ffd10995c044
|
7
|
+
data.tar.gz: c42e9f56269148c3574a7ad10c9b153fa294e54c45b14a5d0e2500af4d9a3d1a68cbd157bba70cec72d591ee28dfa5c7aa15e6c9cdde748f0f30c331720b3477
|
@@ -13,9 +13,9 @@ spec = Gem::Specification.new do |s|
|
|
13
13
|
s.email = "pejuko@gmail.com"
|
14
14
|
s.authors = ["Petr Kovar"]
|
15
15
|
s.name = 'i18n-translators-tools'
|
16
|
-
s.version = '0.2.
|
16
|
+
s.version = '0.2.6'
|
17
17
|
s.date = Time.now.strftime("%Y-%m-%d")
|
18
|
-
s.add_dependency('i18n', '>= 0.
|
18
|
+
s.add_dependency('i18n', '>= 0.7.0')
|
19
19
|
s.add_dependency('ya2yaml')
|
20
20
|
s.require_path = 'lib'
|
21
21
|
s.files = ["bin/i18n-translate", "README.md", "i18n-translators-tools.gemspec", "Rakefile"]
|
@@ -52,6 +52,9 @@ Functions:
|
|
52
52
|
* statistics
|
53
53
|
|
54
54
|
Changelog:
|
55
|
+
v0.2.6
|
56
|
+
* compatible with i18n 0.7.0
|
57
|
+
* make it works with rails 4.2
|
55
58
|
v0.2.5
|
56
59
|
* fix recursive directory scan (-r and --deep options should work now)
|
57
60
|
* enables usage require 'i18n-translators-tools'
|
@@ -18,22 +18,39 @@ module I18n
|
|
18
18
|
# wrapper which can work with both format
|
19
19
|
# the simple and the Translator's
|
20
20
|
def translate(locale, key, options = {})
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
raise InvalidLocale.new(locale) unless locale
|
22
|
+
entry = key && lookup(locale, key, options[:scope], options)
|
23
|
+
entry = translate_to_i18n(entry)
|
24
|
+
|
25
|
+
if options.empty?
|
26
|
+
entry = resolve(locale, key, entry, options)
|
27
|
+
else
|
28
|
+
count, default = options.values_at(:count, :default)
|
29
|
+
values = options.except(*RESERVED_KEYS)
|
30
|
+
entry = entry.nil? && default ?
|
31
|
+
default(locale, key, default, options) : resolve(locale, key, entry, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
throw(:exception, I18n::MissingTranslation.new(locale, key, options)) if entry.nil?
|
35
|
+
entry = entry.dup if entry.is_a?(String)
|
36
|
+
|
37
|
+
entry = pluralize(locale, entry, count) if count
|
38
|
+
entry = translate_to_i18n(entry) # after pluralization there can be enhanced format
|
39
|
+
entry = entry.dup if entry.is_a?(String)
|
40
|
+
entry = interpolate(locale, entry, values) if values
|
41
|
+
|
42
|
+
#throw(:exception, I18n::MissingTranslation.new(locale, key, options)) if entry.to_s.empty?
|
43
|
+
|
44
|
+
entry
|
45
|
+
end
|
32
46
|
|
33
|
-
|
34
|
-
tr = interpolate(locale, tr, values) if values
|
47
|
+
protected
|
35
48
|
|
36
|
-
|
49
|
+
def translate_to_i18n(entry)
|
50
|
+
if entry.is_a?(Hash) && (entry[:translation] || entry[:t] || entry[:default])
|
51
|
+
entry = entry[:translation] || entry[:t] || entry[:default]
|
52
|
+
end
|
53
|
+
entry
|
37
54
|
end
|
38
55
|
|
39
56
|
end # module Backend::Translator
|
data/test/all.rb
CHANGED
@@ -87,6 +87,7 @@ I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
|
|
87
87
|
I18n::Backend::Simple.send(:include, I18n::Backend::PO)
|
88
88
|
I18n::Backend::Simple.send(:include, I18n::Backend::TS)
|
89
89
|
I18n::Backend::Simple.send(:include, I18n::Backend::Properties)
|
90
|
+
I18n.config.enforce_available_locales = false
|
90
91
|
I18n.default_locale = 'default'
|
91
92
|
I18n.locale = 'cze'
|
92
93
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-translators-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Kovar
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.7.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ya2yaml
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +130,9 @@ post_install_message: |
|
|
130
130
|
* statistics
|
131
131
|
|
132
132
|
Changelog:
|
133
|
+
v0.2.6
|
134
|
+
* compatible with i18n 0.7.0
|
135
|
+
* make it works with rails 4.2
|
133
136
|
v0.2.5
|
134
137
|
* fix recursive directory scan (-r and --deep options should work now)
|
135
138
|
* enables usage require 'i18n-translators-tools'
|