lost_in_translations 1.4.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lost_in_translations/translator/base.rb +11 -2
- data/lib/lost_in_translations/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c194760e2f6f01d9d6f0d9d0b139e71edf2304897218152e36f5ce50ed77d555
|
4
|
+
data.tar.gz: 9e7ace56639786f9598ca00fa6e93df1085f5a829d31719402151b8ac05bb94f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f18f7b5494748bdd355c3118005cd15033dafb304e4f0982f3efaabfb750da72634dfb6f4a09180dd4f27c57586f289d2cf8f490f6d19d38adf7baef979405f7
|
7
|
+
data.tar.gz: 27570b827895ef53ad4b97dd2446b54930fda83b2397be157d56485cd916eaf3a1a282d56d072a9cfc81239840de86e2b5c8614cbae3613bcb71b778246aaed1
|
@@ -6,7 +6,7 @@ module LostInTranslations
|
|
6
6
|
|
7
7
|
data = translation_data(object)
|
8
8
|
|
9
|
-
translations = data
|
9
|
+
translations = try_get_translations(data, locale) || {}
|
10
10
|
|
11
11
|
translations[field.to_sym] || translations[field.to_s]
|
12
12
|
end
|
@@ -14,7 +14,7 @@ module LostInTranslations
|
|
14
14
|
def self.assign_translation(object, field, value, locale)
|
15
15
|
data = translation_data(object)
|
16
16
|
|
17
|
-
translations = data
|
17
|
+
translations = try_get_translations(data, locale)
|
18
18
|
|
19
19
|
translations ||= data[locale.to_sym] = {}
|
20
20
|
|
@@ -56,6 +56,15 @@ module LostInTranslations
|
|
56
56
|
|
57
57
|
locale
|
58
58
|
end
|
59
|
+
|
60
|
+
def self.try_get_translations(data, locale)
|
61
|
+
short_locale = locale.to_s.split('-')[0]
|
62
|
+
|
63
|
+
data[locale.to_sym] ||
|
64
|
+
data[locale.to_s] ||
|
65
|
+
data[short_locale.to_sym] ||
|
66
|
+
data[short_locale.to_s]
|
67
|
+
end
|
59
68
|
end
|
60
69
|
end
|
61
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lost_in_translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StreetBees Dev Team
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.49.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.49.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 4.2.
|
103
|
+
version: 4.2.7.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 4.2.
|
110
|
+
version: 4.2.7.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: codeclimate-test-reporter
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|