translate_enum 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +2 -0
- data/README.md +13 -3
- data/lib/translate_enum/builder.rb +4 -0
- data/lib/translate_enum/version.rb +1 -1
- data/lib/translate_enum.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e77857ff770931aacd8caa9d704f2678d6befd15cf830a33821fe6a594c61558
|
|
4
|
+
data.tar.gz: 5741720d55c013d5b7490a56eecb5fccf9a7e60f53ff1c9e578939c651b2e44a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8eb9415674c8b1cb5d768243c10468ad5b57682501000beaf304fa3074e10d7ec06c55d71dbf6c0bb72024fb31af6b2ef73ecef2f9c51746a1e89450de2ff728
|
|
7
|
+
data.tar.gz: 4d6556564500f1bf540b7b02359d2b15ee0422327a6ece5afd3d95650da1ed51a8542873bd8b9967ab933507f2480b9658c366982d85173a40e08645d72d7997
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
|
@@ -31,12 +31,22 @@ en:
|
|
|
31
31
|
post:
|
|
32
32
|
status_list:
|
|
33
33
|
published: Was published
|
|
34
|
-
archive: Was
|
|
34
|
+
archive: Was archived
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or if you wish your locales to be available across all models
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
en:
|
|
41
|
+
attributes:
|
|
42
|
+
status_list:
|
|
43
|
+
published: Was published
|
|
44
|
+
archive: Was archived
|
|
35
45
|
```
|
|
36
46
|
|
|
37
47
|
```ruby
|
|
38
48
|
Post.translated_status(:published) #=> "Was published"
|
|
39
|
-
Post.translated_statuses => [["Was published", :published, 0], ["Was
|
|
49
|
+
Post.translated_statuses => [["Was published", :published, 0], ["Was archived", :archive, 1]]
|
|
40
50
|
|
|
41
51
|
@post = Post.new(status: :published)
|
|
42
52
|
@post.translated_status #=> "Was published"
|
|
@@ -46,7 +56,7 @@ Post.translated_statuses => [["Was published", :published, 0], ["Was achieved",
|
|
|
46
56
|
|
|
47
57
|
```haml
|
|
48
58
|
= form_for @post do |f|
|
|
49
|
-
= f.select :status, options_for_select(f.object.translated_statuses.map { |translation, k, _v| [translation, k] })
|
|
59
|
+
= f.select :status, options_for_select(f.object.class.translated_statuses.map { |translation, k, _v| [translation, k] })
|
|
50
60
|
```
|
|
51
61
|
|
|
52
62
|
## Extending ActiveRecord
|
data/lib/translate_enum.rb
CHANGED
|
@@ -21,7 +21,7 @@ module TranslateEnum
|
|
|
21
21
|
|
|
22
22
|
# User.translated_status(:active)
|
|
23
23
|
define_singleton_method(builder.method_name_singular) do |key|
|
|
24
|
-
I18n.translate(builder.i18n_location(key),
|
|
24
|
+
I18n.translate("#{builder.i18n_scope}.#{builder.i18n_location(key)}", default: builder.i18n_default_location(key))
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# @return [Array]
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: translate_enum
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aliaksandr Shylau
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
|
117
117
|
files:
|
|
118
118
|
- ".gitignore"
|
|
119
119
|
- ".rspec"
|
|
120
|
+
- CHANGELOG.md
|
|
120
121
|
- Gemfile
|
|
121
122
|
- README.md
|
|
122
123
|
- Rakefile
|
|
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
146
147
|
version: '0'
|
|
147
148
|
requirements: []
|
|
148
149
|
rubyforge_project:
|
|
149
|
-
rubygems_version: 2.
|
|
150
|
+
rubygems_version: 2.7.3
|
|
150
151
|
signing_key:
|
|
151
152
|
specification_version: 4
|
|
152
153
|
summary: Rails translate enum
|