chipairon-i18n-active_record 0.0.3 → 0.0.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 798056b0e6fbacf7b98182202e34af8e23e16585
|
4
|
+
data.tar.gz: cc430df424903e741138ef98d78c95224738a4cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f8daec77a6c348cd500bd0dd63c5df0b9a36f079fd753bae1ba6e3f41a6eff07765432a9c3c16199316b697e79a4e34f951124acf7bdd64b2f154c17b70fa29
|
7
|
+
data.tar.gz: deb3bcf0c44a4d7bfc479d11537eb3417a3b34424131addafed1d6c98e3dfe0fe789b3e28ca1f8d78a11626b6d6784413974aa779cc6d5808ceb4676799091cd
|
@@ -41,23 +41,23 @@ module I18n
|
|
41
41
|
key = normalize_flat_keys(locale, key, scope, separator)
|
42
42
|
interpolations = options.keys - I18n::RESERVED_KEYS
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
store_if_not_exists(a_locale, key, interpolations, count)
|
44
|
+
unless ActiveRecord::Translation.locale(locale).lookup(key).exists?
|
45
|
+
if I18n::available_locales.any?
|
46
|
+
I18n::available_locales.each do |a_locale|
|
47
|
+
store_if_not_exists(a_locale, key, interpolations, count)
|
48
|
+
end
|
49
|
+
else
|
50
|
+
store_if_not_exists(locale, key, interpolations, count)
|
52
51
|
end
|
53
|
-
|
54
|
-
|
52
|
+
# if memoization is included, this refreshes the hash to get new values just stored
|
53
|
+
try(:reload!)
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
57
|
def store_default_translation(locale, key, interpolations)
|
59
58
|
translation = ActiveRecord::Translation.new :locale => locale.to_s, :key => key
|
60
59
|
translation.interpolations = interpolations
|
60
|
+
translation.value = get_value_from_simple_backend(locale, key)
|
61
61
|
translation.save
|
62
62
|
end
|
63
63
|
|
@@ -85,6 +85,18 @@ module I18n
|
|
85
85
|
end
|
86
86
|
plurals
|
87
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
# Check if this backend is chainning with simple
|
91
|
+
# then try to get value from its hash.
|
92
|
+
def get_value_from_simple_backend(locale, key)
|
93
|
+
if I18n.backend.class == Chain &&
|
94
|
+
I18n.backend.backends.last.class == Simple
|
95
|
+
I18n.backend.backends.last.send(:lookup, locale, key)
|
96
|
+
else
|
97
|
+
nil
|
98
|
+
end
|
99
|
+
end
|
88
100
|
end
|
89
101
|
end
|
90
102
|
end
|
@@ -41,6 +41,7 @@ module I18n
|
|
41
41
|
key = normalize_flat_keys(locale, key, scope, separator)
|
42
42
|
interpolations = options.keys - I18n::RESERVED_KEYS
|
43
43
|
|
44
|
+
<<<<<<< HEAD
|
44
45
|
# if already memoized, then a record already exists.
|
45
46
|
if @memoized_lookup and @memoized_lookup[locale.to_sym].keys.include? key.to_sym
|
46
47
|
return
|
@@ -52,24 +53,22 @@ module I18n
|
|
52
53
|
end
|
53
54
|
else
|
54
55
|
store_if_not_exists(locale, key, interpolations, count)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def store_if_not_exists(locale, key, interpolations, count)
|
59
|
-
unless ActiveRecord::Translation.locale(locale).lookup(key).exists?
|
60
|
-
<<<<<<< HEAD
|
61
|
-
keys = count ? I18n.t('i18n.plural.keys', :locale => locale).map { |k| [key, k].join(FLATTEN_SEPARATOR) } : [key]
|
62
56
|
=======
|
57
|
+
unless ActiveRecord::Translation.locale(locale).lookup(key).exists?
|
63
58
|
interpolations = options.keys - I18n::RESERVED_KEYS
|
64
|
-
keys = count ?
|
65
|
-
>>>>>>> e4d6427a8d4550e773199bef8410dcbe5f175f62
|
59
|
+
keys = count ? I18n.t('i18n.plural.keys', :locale => locale).map { |k| [key, k].join(FLATTEN_SEPARATOR) } : [key]
|
66
60
|
keys.each { |key| store_default_translation(locale, key, interpolations) }
|
61
|
+
|
62
|
+
# if memoization is included, this refreshes the hash to get new values just stored
|
63
|
+
try(:reload!)
|
64
|
+
>>>>>>> 5dfbeffc11eed8fb7cf0313fa6288d34417bf38d
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
70
68
|
def store_default_translation(locale, key, interpolations)
|
71
69
|
translation = ActiveRecord::Translation.new :locale => locale.to_s, :key => key
|
72
70
|
translation.interpolations = interpolations
|
71
|
+
translation.value = get_value_from_simple_backend(locale, key)
|
73
72
|
translation.save
|
74
73
|
end
|
75
74
|
|
@@ -80,6 +79,15 @@ module I18n
|
|
80
79
|
end
|
81
80
|
|
82
81
|
private
|
82
|
+
<<<<<<< HEAD
|
83
|
+
|
84
|
+
def store_if_not_exists(locale, key, interpolations, count)
|
85
|
+
unless ActiveRecord::Translation.locale(locale).lookup(key).exists?
|
86
|
+
keys = count ? get_plurals(locale).map { |k| [key, k].join(FLATTEN_SEPARATOR) } : [key]
|
87
|
+
keys.each { |key| store_default_translation(locale, key, interpolations) }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
83
91
|
# get plural rules or use English rules as default:
|
84
92
|
def get_plurals(locale)
|
85
93
|
plurals = I18n.t('i18n.plural.keys', :locale => locale)
|
@@ -88,6 +96,17 @@ module I18n
|
|
88
96
|
plurals = [:zero, :one, :other]
|
89
97
|
end
|
90
98
|
plurals
|
99
|
+
=======
|
100
|
+
# Check if this backend is chainning with simple
|
101
|
+
# then try to get value from its hash.
|
102
|
+
def get_value_from_simple_backend(locale, key)
|
103
|
+
if I18n.backend.class == Chain &&
|
104
|
+
I18n.backend.backends.last.class == Simple
|
105
|
+
I18n.backend.backends.last.send(:lookup, locale, key)
|
106
|
+
else
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
>>>>>>> 5dfbeffc11eed8fb7cf0313fa6288d34417bf38d
|
91
110
|
end
|
92
111
|
end
|
93
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chipairon-i18n-active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|