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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hola_milind_patel.rb +35 -35
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23bad1918baca470ebf1d5fa903637a84ed691a2546f168c697506dfb6661a05
4
- data.tar.gz: 8c6f99ea9347cd84442dbf7a42a53b8d6f5666eedd3f93a384330ee58f130682
3
+ metadata.gz: e7523a1f8af3cc485c55f2cffa525a1bf6c5c6ec84d356f12119549a873e0fa9
4
+ data.tar.gz: 50d9e02668aa8113b6c7fc900e085ba2f1ab7fe7993300985b4ede09b8e1881e
5
5
  SHA512:
6
- metadata.gz: 8de69600cdd111985121bbdfcde9ccaa7b84d5a45fec48cb7757b78debf8a216c184a096bd853126f237ef096230814587a9a5f9c81a6c01b9ce880ea1981ad8
7
- data.tar.gz: 0aae83a435889eff83f2d9c16cc7c4b431f93d457c194a3db562a89e35ad9d501ec85ee0083eb8060ca9616594d31360e2b5931e50e6690e2354d484b1018bb0
6
+ metadata.gz: 962e9c4d55ca8f2469ba8f39c30a3bc2ea10eb373076d2832af94c14413b9dfb85e18dc04b2f13c8309026a2d78b6ad6719e794338dfce58215719d6c237acdc
7
+ data.tar.gz: cb05304f201500e1601508cf461999f742428265d12e90131e781d81e62b8dc9669249274c3d1ea9a5e1442d2c73ad4e305a58c4d9245ce36891d64257f1a199
@@ -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
- puts "============================================================"
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
- HolaMilindPatel.locale = ENV['LANGUAGE']
23
- #Mobility.locale = language
24
- centers = data.as_json
25
- if ENV['STRICT'] == "true"
26
- centers.map do |center|
27
- center.as_json.each do |key,value|
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
- end
39
+ center
40
+ end
36
41
  end
37
42
  return centers
38
43
  end
44
+
39
45
  def self.getShowData(data)
40
- puts "============================================================"
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
- HolaMilindPatel.locale = ENV['LANGUAGE']
57
- #Mobility.locale = language
58
- center = data.as_json
59
- if ENV['STRICT'] == "true"
60
- center.each do |key,value|
61
- record = data.class.find(center['id'])
62
- if (data.send("#{key}_backend") rescue "false") != "false"
63
- center[key] = record.send(key.parameterize.underscore.to_sym,fallback: false)
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
- def self.hi
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hola_milind_patel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Milind Patel