hola_milind_patel 0.1.9 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hola_milind_patel.rb +35 -35
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7523a1f8af3cc485c55f2cffa525a1bf6c5c6ec84d356f12119549a873e0fa9
|
4
|
+
data.tar.gz: 50d9e02668aa8113b6c7fc900e085ba2f1ab7fe7993300985b4ede09b8e1881e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962e9c4d55ca8f2469ba8f39c30a3bc2ea10eb373076d2832af94c14413b9dfb85e18dc04b2f13c8309026a2d78b6ad6719e794338dfce58215719d6c237acdc
|
7
|
+
data.tar.gz: cb05304f201500e1601508cf461999f742428265d12e90131e781d81e62b8dc9669249274c3d1ea9a5e1442d2c73ad4e305a58c4d9245ce36891d64257f1a199
|
data/lib/hola_milind_patel.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'mobility'
|
2
2
|
module HolaMilindPatel
|
3
|
+
|
4
|
+
def self.translate(data)
|
5
|
+
responce = getData(data) if !data[0].nil?
|
6
|
+
responce = getShowData(data) if data[0].nil?
|
7
|
+
return responce
|
8
|
+
end
|
9
|
+
|
3
10
|
def self.getData(data)
|
4
|
-
|
5
|
-
puts "Function getData Called"
|
6
|
-
puts "============================================================"
|
7
|
-
if ENV['LANGUAGE'] == "all"
|
11
|
+
if RequestStore.store[:selected_language] == "all"
|
8
12
|
centers = data.as_json
|
9
13
|
centers.map do |center|
|
10
14
|
c1 = data.klass.find(center['id'])
|
@@ -19,28 +23,27 @@ module HolaMilindPatel
|
|
19
23
|
center
|
20
24
|
end
|
21
25
|
else
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
record = data.klass.find(center['id'])
|
29
|
-
if (record.send("#{key}_backend") rescue "false") != "false"
|
26
|
+
centers = data.as_json
|
27
|
+
centers.map do |center|
|
28
|
+
center.as_json.each do |key,value|
|
29
|
+
record = data.klass.find(center['id'])
|
30
|
+
if (record.send("#{key}_backend") rescue "false") != "false"
|
31
|
+
if RequestStore.store[:strict] == "true"
|
30
32
|
center[key] = record.send(key.parameterize.underscore.to_sym,fallback: false)
|
33
|
+
else
|
34
|
+
center[key] = record.send(key.parameterize.underscore.to_sym,fallback: record.default_language.parameterize.underscore.to_sym)
|
35
|
+
#center[key] = record.send(key.parameterize.underscore.to_sym,fallback: I18n.default_locale)
|
31
36
|
end
|
32
37
|
end
|
33
|
-
center
|
34
38
|
end
|
35
|
-
|
39
|
+
center
|
40
|
+
end
|
36
41
|
end
|
37
42
|
return centers
|
38
43
|
end
|
44
|
+
|
39
45
|
def self.getShowData(data)
|
40
|
-
|
41
|
-
puts "Function getShowData Called"
|
42
|
-
puts "============================================================"
|
43
|
-
if ENV['LANGUAGE'] == "all"
|
46
|
+
if RequestStore.store[:selected_language] == "all"
|
44
47
|
center = data
|
45
48
|
c = center.as_json
|
46
49
|
center.as_json.each do |key,value|
|
@@ -53,29 +56,26 @@ module HolaMilindPatel
|
|
53
56
|
end
|
54
57
|
return c
|
55
58
|
else
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
center[key] =
|
59
|
+
center = data.as_json
|
60
|
+
center.each do |key,value|
|
61
|
+
if (data.send("#{key}_backend") rescue "false") != "false"
|
62
|
+
obj = JSON.parse(center.to_json,object_class: data.class)
|
63
|
+
if RequestStore.store[:strict] == "true"
|
64
|
+
center[key] = obj.send(key.parameterize.underscore.to_sym,fallback: false)
|
65
|
+
else
|
66
|
+
center[key] = obj.send(key.parameterize.underscore.to_sym,fallback: obj.default_language.parameterize.underscore.to_sym)
|
67
|
+
# center[key] = obj.send(key.parameterize.underscore.to_sym,fallback: I18n.default_locale)
|
64
68
|
end
|
65
69
|
end
|
66
|
-
end
|
70
|
+
end
|
67
71
|
return center
|
68
72
|
end
|
69
73
|
end
|
70
|
-
|
71
|
-
puts "===================="
|
72
|
-
puts "Hello Milind! Your Gem is working!!"
|
73
|
-
puts "===================="
|
74
|
-
end
|
74
|
+
|
75
75
|
class << self
|
76
76
|
def locale=(locale)
|
77
|
-
Mobility.locale = locale
|
78
|
-
puts "Locale has been set to " + locale
|
77
|
+
Mobility.locale = locale || I18n.default_locale
|
79
78
|
end
|
80
|
-
end
|
79
|
+
end
|
80
|
+
|
81
81
|
end
|