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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94899fa31aad1c22083125064d145f3f955cd5c7d895cabf547c89e218baf907
4
- data.tar.gz: 48cf57640178e2f5f22210eb95ce71d784885fed9cf06f4e2594f1cbac8bcf6b
3
+ metadata.gz: c194760e2f6f01d9d6f0d9d0b139e71edf2304897218152e36f5ce50ed77d555
4
+ data.tar.gz: 9e7ace56639786f9598ca00fa6e93df1085f5a829d31719402151b8ac05bb94f
5
5
  SHA512:
6
- metadata.gz: 476dec88ac5c73978729a095955d124e84e38b542c4bd31f0448f65bd182f695faeb86ae509689b65f5495d6d718f828e7d6b1e9721d2463a58e677b4c06cdae
7
- data.tar.gz: ea672a70d24764931eb85f42d80c0909c06446707987ca9f0166d1c0a22ce060434c47b58a7783e20cf8270ef18315cf1bfd12222c9dae4457c7741c59790c2e
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[locale.to_sym] || data[locale.to_s] || {}
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[locale.to_sym] || data[locale.to_s]
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
@@ -1,3 +1,3 @@
1
1
  module LostInTranslations
2
- VERSION = '1.4.3'.freeze
2
+ VERSION = '1.5.0'.freeze
3
3
  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.3
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.37.2
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.37.2
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.6
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.6
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