awesome_translations 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/awesome_translations/handler.rb +8 -4
  3. data/lib/awesome_translations/handlers/base_handler.rb +34 -0
  4. data/lib/awesome_translations/handlers/devise_handler.rb +107 -0
  5. data/lib/awesome_translations/handlers/rails_handler.rb +0 -31
  6. data/lib/awesome_translations/handlers/will_paginate_handler.rb +54 -0
  7. data/lib/awesome_translations/handlers.rb +2 -0
  8. data/lib/awesome_translations/version.rb +1 -1
  9. data/spec/dummy/db/development.sqlite3 +0 -0
  10. data/spec/dummy/log/development.log +748 -0
  11. data/spec/dummy/log/test.log +1136 -0
  12. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/1qKcXfkG8CKi7q4pCEHnvwfcPx1E_x2I7eSOQBHGPPY.cache +2 -0
  13. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/1vIoFrjnL-WYo6h0P4YR6R8em3JmI3g-ordATsUyh60.cache +3 -0
  14. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/2E1pK4UD0p2JhztN3ZkvvMpu6_XhIhetM_kYdv3qIkI.cache +1 -0
  15. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/3IscdSBVlh2QpX_V8gWbAdJn0CwOi3CtjBf841bLw90.cache +0 -0
  16. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/3UCczbToeiY2ykHpeDqRi9GK-6t_Elikr8hOWGdAUzk.cache +0 -0
  17. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/5wfdkfw9Q56zdQjDm46Dd76F-Bh_TXOMtg-yo9qWK-4.cache +2 -0
  18. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6Tt3BohHWhW0VmHcKYyX9vLJY8ZGHF9XKASbNndcriw.cache +0 -0
  19. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6VoVHZXlkZRSXoEKqnyAKlNmd0nYvRv4gysdIYMMPO0.cache +0 -0
  20. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ABmSicIQVooWccPPNziw-INMNKnC2fTrf0gZOo4D-Uo.cache +0 -0
  21. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/FMw8p0XzZq8ibZDT5V9xwtSvsD4kE6KUFZ757QLIaaA.cache +1 -0
  22. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/GApQ59e5HgUPx8vhnO4eQLAaEDRattds4frtXbteIKU.cache +1 -0
  23. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/GEBEpe470v7Q9mkDELNzG8WQfzdSL--qJ5JGJ8sG40w.cache +1 -0
  24. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/I2mbvQlKAUa_sKfXDn60m_2SHHDJg5d0q0A-D82H5CU.cache +1 -0
  25. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/K9eViHXJLIL05Z-rEIFPZ1ey9Y7iEnaM1nQjV6xUjvw.cache +2 -0
  26. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KA2Lwg2NNgt_oqtKVifbp_KCzBYpUOESd_vhyofiHuM.cache +1 -0
  27. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KI5ikH1EhRt8UcY_TnNsPFctrbR_XR870QmQiiS_LWY.cache +2 -0
  28. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KK-iVi_zk3sBOAMMmX8qOKilgTXSJ6VR7ev4cCt-xiw.cache +1 -0
  29. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KUMOTC_lyk0EVRIY2QOPuyhGxA5lBKWZk2g6dsB_GFk.cache +0 -0
  30. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/LJY_42VtPPzKbYI_08t0RibCYO6Pk7h_D5LVUqMUf08.cache +2 -0
  31. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MIEij_krgXGgx1NoadOVjN0zUctja-Ju8dW9X1BrIZc.cache +2 -0
  32. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Mb5rz8ZE56o6DQO3S0TzatTW70GbYDOj6TGqPtaiR4E.cache +2 -0
  33. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MvZLakajvgchZhakOLhaUlcPKa04GDMcx4Cb79n77l8.cache +1 -0
  34. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/NAVJvwEfjb_iCvtQZ87F4LttFQX1ELd2TGRMzda1YTM.cache +1 -0
  35. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/RpvlWDvKjlJIn18TwRI_mqrAq5fq3ZKBoIZ7j6J0VS8.cache +1 -0
  36. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UezSt2l9DKvGH5FTKMGncQA2frZcqiwBpjNNGY5YxJE.cache +2 -0
  37. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Up99B1IcqjCl5pX4oDOUjBRH7MlGkanhw2U4jblusws.cache +3 -0
  38. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Vp5XbjUwVj8XafOL_dOz2pN9bIF-biEbxFPY3KTemjY.cache +1 -0
  39. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ZotICrlgxuCoyrHNZjO5OdWgcDSnUFNtW3XFWiNrmZI.cache +2 -0
  40. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/_3WzdzBWQ6Aal-8jujuXrujK4QhMa397rqUYFLR-NQM.cache +1 -0
  41. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/_8zNerD1S8oKB2XaiZXtPXacVT50V1pzgDmwm1T0FYg.cache +1 -0
  42. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/awwp95szKjLN7ecKC_knYGqSFX7fSIUN6aZfZSoK4go.cache +2 -0
  43. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/bCh19eCSHzJLYGCtRk1UwrrR1H5sQGXneb7YXxFB2rM.cache +0 -0
  44. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/chB-Km9txyW42AEZsCObxy_RTOKPUaXoueiIl-pu3UU.cache +0 -0
  45. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/d0dz_SPKXqz2hMYTGWtbe15XFuke1sEBI_1X_O_P7ZY.cache +0 -0
  46. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/dFQ4Q3hp4VwfHzoh2lVeOsYsY87Li26plRX4uWWDISs.cache +0 -0
  47. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/db4IzdQ8LsevZeJT0IY5KrjEko5oPwd9zNfqUHrO6sA.cache +0 -0
  48. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/hFeUW0u2l1yvMNYKs8aTAjGPox_WiHs3sWdpviW8j8g.cache +0 -0
  49. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/hTX85qeo1RVM_iwikMQZrzHAqrP6Z8jFf-KH_GgsSwo.cache +1 -0
  50. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/k7ZFNEy7rPvT30E_q2ktyQj9ZbIMivSf-QxyW9TA5xw.cache +0 -0
  51. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/k8M9V_ClpoQ0s1OMUJHaJfk4qPcAYqeJQ5GcRTqQSA8.cache +1 -0
  52. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/kExbfVgvjJlXnJKkTOLOYYVvm9RnXiAXbtxmHx7oQV8.cache +1 -0
  53. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/kXZ5SNrnAE-T54v1b_KddSictfSfwOSoj7H4i5-6f8g.cache +0 -0
  54. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/kp77YxQaf2YTdZ8WZlB3LYnulhMMhGfSRhqeA9qaffQ.cache +1 -0
  55. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/kyxMBV6uZkWe3IRCYC22nz50pqdEvoUf29oOIKfqnLY.cache +0 -0
  56. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/l32RrzgTsAGwpwA3LGrqcKRHthaL681N18TiyrJ3goM.cache +1 -0
  57. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/m0Ed6UHlyVF0HkWQFgMHYw21q7KL7ChRRX7kJOLOd4A.cache +1 -0
  58. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/nACk4K2RvtLpl83m8PVDPJx8O5oW197e1COjCELFQkE.cache +0 -0
  59. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/noLGhxn9iGEF7BDE8GTG2LLTuFPgxT-yM1F0obB5nGM.cache +1 -0
  60. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/oN2LUbJ3UjOO--J2XELuQnD2XIq80Oa2bc5WYwhDK3c.cache +1 -0
  61. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/osR7Wt_1B7LezjwxH6ANK96EPg1Jy808ubXAfIYat6k.cache +0 -0
  62. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/uXmtB4n5IxofIKBQSzzHvvz7XJj3y6ul-AW0B5F_Fis.cache +0 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/w6gYjUBGcix9jkTtmox9zOg5RMDExUrt0LeoOEU49Ww.cache +1 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/y6orTmm6rk6jn-CJIAXeQ8rOaHkBHFtbPogJm-3dNqE.cache +0 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/zPWQ3Dit7vGxRBJDr0Y6060syWEljgLfPpBSwT_awWo.cache +0 -0
  66. metadata +116 -4
  67. data/spec/dummy/config/locales/awesome_translations/date_time/da.yml +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c153541f63daa0e76bab656ef63b427158166bb4
4
- data.tar.gz: e2b1664ac4cd784e9538c139e50eca544b28f00a
3
+ metadata.gz: 1b767303de03d7364fb0c7212a3e6904a76cd248
4
+ data.tar.gz: cd3acf8f7db3af66c9d94b503b398004a329bc65
5
5
  SHA512:
6
- metadata.gz: c7d391a84f64478fd5d02af9f5bf64e9536142ebb6581e61c87337c561313a24b6ce2df799bb3a5c6e290bd3debddd1d7ca57312a25bf87ab1aea6085e721a27
7
- data.tar.gz: fe4c5062bb32bc1ccef8f6c8eeadc1416c9be5850dbd9578157c32914651c0ceb157b271ced2786045812cf2e97df3ede1282f78a31753a6f9b701b81f75fa8e
6
+ metadata.gz: a763bd92feb3e84d48da83086a1b0535a3c986ea38968a99711a315a149b045d89de41a43901537f28d136c92407d3780f7981aafdc016383811b7ee9f8e9d1f
7
+ data.tar.gz: ba665effaa13e98405710640ff9cb6a22193127428a73d1f6a9c92f61e93ed12da92144ccd60bb2407024a4bdb757817fa2de0244e50ac53339f9d92bb19d288
@@ -16,7 +16,7 @@ class AwesomeTranslations::Handler
16
16
  end
17
17
 
18
18
  def id
19
- @data[:id]
19
+ @data.fetch(:id)
20
20
  end
21
21
 
22
22
  def to_param
@@ -28,15 +28,19 @@ class AwesomeTranslations::Handler
28
28
  end
29
29
 
30
30
  def name
31
- @data[:name]
31
+ @data.fetch(:name)
32
32
  end
33
33
 
34
34
  def const
35
- AwesomeTranslations::Handlers.const_get(@data[:const_name])
35
+ AwesomeTranslations::Handlers.const_get(@data.fetch(:const_name))
36
+ end
37
+
38
+ def instance
39
+ const.new
36
40
  end
37
41
 
38
42
  def translations
39
- const.new.translations
43
+ instance.translations
40
44
  end
41
45
 
42
46
  def groups
@@ -1,2 +1,36 @@
1
1
  class AwesomeTranslations::Handlers::BaseHandler
2
+ def add_translations_for_hash(dir, group, yielder, hash)
3
+ translations_for_hash_recursive(dir, hash[:translations], yielder, [])
4
+ end
5
+
6
+ def translations_for_hash_recursive(dir, hash, yielder, current_keys)
7
+ hash.each do |key, value|
8
+ current_keys << key
9
+
10
+ if value.is_a?(Hash)
11
+ translations_for_hash_recursive(dir, value, yielder, current_keys)
12
+ elsif value.is_a?(Array)
13
+ value.each_index do |index|
14
+ yielder << AwesomeTranslations::Translation.new(
15
+ dir: dir,
16
+ key: "#{current_keys.join('.')}[#{index}]",
17
+ key_show: "#{current_keys.join('.')}[#{index}]"
18
+ )
19
+ end
20
+ else
21
+ yielder << AwesomeTranslations::Translation.new(
22
+ dir: dir,
23
+ key: current_keys.join('.'),
24
+ key_show: current_keys.join('.'),
25
+ default: value
26
+ )
27
+ end
28
+
29
+ current_keys.pop
30
+ end
31
+ end
32
+
33
+ def enabled?
34
+ true
35
+ end
2
36
  end
@@ -0,0 +1,107 @@
1
+ class AwesomeTranslations::Handlers::DeviseHandler < AwesomeTranslations::Handlers::BaseHandler
2
+ def enabled?
3
+ ::Object.const_defined?(:Devise)
4
+ end
5
+
6
+ def groups
7
+ ArrayEnumerator.new do |yielder|
8
+ groups = ['devise']
9
+
10
+ groups.each do |group|
11
+ yielder << AwesomeTranslations::Group.new(
12
+ id: group,
13
+ handler: self,
14
+ data: {
15
+ name: group.humanize
16
+ }
17
+ )
18
+ end
19
+ end
20
+ end
21
+
22
+ def translations_for_group(group)
23
+ ArrayEnumerator.new do |yielder|
24
+ dir = Rails.root.join('config', 'locales', 'awesome_translations', group.id).to_s
25
+ __send__("translations_for_#{group.id}", dir, group, yielder)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def translations_for_devise(dir, group, yielder)
32
+ add_translations_for_hash(dir, group, yielder, translations: {
33
+ devise: {
34
+ confirmations: {
35
+ confirmed: "Your email address has been successfully confirmed.",
36
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes.",
37
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
38
+ },
39
+ failure: {
40
+ already_authenticated: "You are already signed in.",
41
+ inactive: "Your account is not activated yet.",
42
+ invalid: "Invalid %{authentication_keys} or password.",
43
+ locked: "Your account is locked.",
44
+ last_attempt: "You have one more attempt before your account is locked.",
45
+ not_found_in_database: "Invalid %{authentication_keys} or password.",
46
+ timeout: "Your session expired. Please sign in again to continue.",
47
+ unauthenticated: "You need to sign in or sign up before continuing.",
48
+ unconfirmed: "You have to confirm your email address before continuing."
49
+ },
50
+ mailer: {
51
+ confirmation_instructions: {
52
+ subject: "Confirmation instructions"
53
+ },
54
+ reset_password_instructions: {
55
+ subject: "Reset password instructions"
56
+ },
57
+ unlock_instructions: {
58
+ subject: "Unlock instructions"
59
+ }
60
+ },
61
+ omniauth_callbacks: {
62
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\".",
63
+ success: "Successfully authenticated from %{kind} account."
64
+ },
65
+ passwords: {
66
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided.",
67
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes.",
68
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes.",
69
+ updated: "Your password has been changed successfully. You are now signed in.",
70
+ updated_not_active: "Your password has been changed successfully."
71
+ },
72
+ registrations: {
73
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon.",
74
+ signed_up: "Welcome! You have signed up successfully.",
75
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated.",
76
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked.",
77
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account.",
78
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address.",
79
+ updated: "Your account has been updated successfully."
80
+ },
81
+ sessions: {
82
+ signed_in: "Signed in successfully.",
83
+ signed_out: "Signed out successfully.",
84
+ already_signed_out: "Signed out successfully."
85
+ },
86
+ unlocks: {
87
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes.",
88
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes.",
89
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
90
+ }
91
+ },
92
+ errors: {
93
+ messages: {
94
+ already_confirmed: "was already confirmed, please try signing in",
95
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one",
96
+ expired: "has expired, please request a new one",
97
+ not_found: "not found",
98
+ not_locked: "was not locked",
99
+ not_saved: {
100
+ one: "1 error prohibited this %{resource} from being saved:",
101
+ other: "%{count} errors prohibited this %{resource} from being saved:"
102
+ }
103
+ }
104
+ }
105
+ })
106
+ end
107
+ end
@@ -174,35 +174,4 @@ private
174
174
  }
175
175
  })
176
176
  end
177
-
178
- def add_translations_for_hash(dir, group, yielder, hash)
179
- translations_for_hash_recursive(dir, hash[:translations], yielder, [])
180
- end
181
-
182
- def translations_for_hash_recursive(dir, hash, yielder, current_keys)
183
- hash.each do |key, value|
184
- current_keys << key
185
-
186
- if value.is_a?(Hash)
187
- translations_for_hash_recursive(dir, value, yielder, current_keys)
188
- elsif value.is_a?(Array)
189
- value.each_index do |index|
190
- yielder << AwesomeTranslations::Translation.new(
191
- dir: dir,
192
- key: "#{current_keys.join('.')}[#{index}]",
193
- key_show: "#{current_keys.join('.')}[#{index}]"
194
- )
195
- end
196
- else
197
- yielder << AwesomeTranslations::Translation.new(
198
- dir: dir,
199
- key: current_keys.join('.'),
200
- key_show: current_keys.join('.'),
201
- default: value
202
- )
203
- end
204
-
205
- current_keys.pop
206
- end
207
- end
208
177
  end
@@ -0,0 +1,54 @@
1
+ class AwesomeTranslations::Handlers::WillPaginateHandler < AwesomeTranslations::Handlers::BaseHandler
2
+ def enabled?
3
+ ::Object.const_defined?(:WillPaginate)
4
+ end
5
+
6
+ def groups
7
+ ArrayEnumerator.new do |yielder|
8
+ groups = ['will_paginate']
9
+
10
+ groups.each do |group|
11
+ yielder << AwesomeTranslations::Group.new(
12
+ id: group,
13
+ handler: self,
14
+ data: {
15
+ name: group.humanize
16
+ }
17
+ )
18
+ end
19
+ end
20
+ end
21
+
22
+ def translations_for_group(group)
23
+ ArrayEnumerator.new do |yielder|
24
+ dir = Rails.root.join('config', 'locales', 'awesome_translations', group.id).to_s
25
+ __send__("translations_for_#{group.id}", dir, group, yielder)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def translations_for_will_paginate(dir, group, yielder)
32
+ add_translations_for_hash(dir, group, yielder, translations: {
33
+ will_paginate: {
34
+ previous_label: "&#8592; Previous",
35
+ next_label: "Next &#8594;",
36
+ page_gap: "&hellip;",
37
+ page_entries_info: {
38
+ single_page: {
39
+ zero: "No %{model} found",
40
+ one: "Displaying 1 %{model}",
41
+ other: "Displaying all %{count} %{model}",
42
+ },
43
+ single_page_html: {
44
+ zero: "No %{model} found",
45
+ one: "Displaying <b>1</b> %{model}",
46
+ other: "Displaying <b>all&nbsp;%{count}</b> %{model}"
47
+ },
48
+ multi_page: "Displaying %{model} %{from} - %{to} of %{count} in total",
49
+ multi_page_html: "Displaying %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> of <b>%{count}</b> in total"
50
+ }
51
+ }
52
+ })
53
+ end
54
+ end
@@ -19,6 +19,8 @@ class AwesomeTranslations::Handlers
19
19
  end
20
20
  end
21
21
 
22
+ @handlers = @handlers.select { |handler| handler.instance.enabled? }
23
+
22
24
  def self.list
23
25
  @handlers
24
26
  end
@@ -1,3 +1,3 @@
1
1
  module AwesomeTranslations
2
- VERSION = '0.0.23'
2
+ VERSION = '0.0.24'
3
3
  end
Binary file