scaffold_cn 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/lib/generators/scaffoldcn/USAGE +15 -0
  6. data/lib/generators/scaffoldcn/scaffoldcn_generator.rb +18 -0
  7. data/lib/generators/scaffoldcn/templates/config/locales/devise.zh-CN.yml +59 -0
  8. data/lib/generators/scaffoldcn/templates/config/locales/model.yml +9 -0
  9. data/lib/generators/scaffoldcn/templates/config/locales/zh-CN.yml +199 -0
  10. data/lib/generators/scaffoldcn/templates/lib/templates/erb/scaffold/_form.html.erb +37 -0
  11. data/lib/generators/scaffoldcn/templates/lib/templates/erb/scaffold/edit.html.erb +6 -0
  12. data/lib/generators/scaffoldcn/templates/lib/templates/erb/scaffold/index.html.erb +29 -0
  13. data/lib/generators/scaffoldcn/templates/lib/templates/erb/scaffold/new.html.erb +5 -0
  14. data/lib/generators/scaffoldcn/templates/lib/templates/erb/scaffold/show.html.erb +11 -0
  15. data/lib/scaffold_cn.rb +4 -0
  16. data/lib/scaffold_cn/version.rb +3 -0
  17. data/test/dummy/README.rdoc +28 -0
  18. data/test/dummy/Rakefile +6 -0
  19. data/test/dummy/app/assets/javascripts/application.js +13 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  21. data/test/dummy/app/controllers/application_controller.rb +5 -0
  22. data/test/dummy/app/helpers/application_helper.rb +2 -0
  23. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  24. data/test/dummy/bin/bundle +3 -0
  25. data/test/dummy/bin/rails +4 -0
  26. data/test/dummy/bin/rake +4 -0
  27. data/test/dummy/config.ru +4 -0
  28. data/test/dummy/config/application.rb +23 -0
  29. data/test/dummy/config/boot.rb +5 -0
  30. data/test/dummy/config/database.yml +25 -0
  31. data/test/dummy/config/environment.rb +5 -0
  32. data/test/dummy/config/environments/development.rb +29 -0
  33. data/test/dummy/config/environments/production.rb +80 -0
  34. data/test/dummy/config/environments/test.rb +36 -0
  35. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/test/dummy/config/initializers/inflections.rb +16 -0
  38. data/test/dummy/config/initializers/mime_types.rb +5 -0
  39. data/test/dummy/config/initializers/secret_token.rb +12 -0
  40. data/test/dummy/config/initializers/session_store.rb +3 -0
  41. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/test/dummy/config/locales/en.yml +23 -0
  43. data/test/dummy/config/routes.rb +4 -0
  44. data/test/dummy/public/404.html +58 -0
  45. data/test/dummy/public/422.html +58 -0
  46. data/test/dummy/public/500.html +57 -0
  47. data/test/dummy/public/favicon.ico +0 -0
  48. data/test/integration/navigation_test.rb +10 -0
  49. data/test/scaffold_cn_test.rb +7 -0
  50. data/test/test_helper.rb +15 -0
  51. metadata +154 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40dd60f7aba1314247ea8a3795b8de4dc523b274
4
+ data.tar.gz: 8c3a1b3e741d1d37793e2235e1483ec80665c34f
5
+ SHA512:
6
+ metadata.gz: aa1b05f12be852cfeae33e68a02429842410c038952bbfcc184f95a2f0405717acaa884a7d2a66d84fe6833429a70993b8f7413efbdb16dd5b4bcb630ffc7cad
7
+ data.tar.gz: faf3df4b1473097b1829e5b9191ab593955875b439cbfe9716dce47e29b056c52b2290032a494277c4440e9cb403265b17bed385caa83baf80baa5cfa2a35cd6
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = ScaffoldCn
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ScaffoldCn'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,15 @@
1
+ Description:
2
+ Translate the scaffold templates to zh_CN.
3
+
4
+ Example:
5
+ rails g scaffoldcn
6
+
7
+ This will create:
8
+ lib/templates/erb/scaffold/_form.html.erb
9
+ lib/templates/erb/scaffold/edit.html.erb
10
+ lib/templates/erb/scaffold/index.html.erb
11
+ lib/templates/erb/scaffold/new.html.erb
12
+ lib/templates/erb/scaffold/show.html.erb
13
+
14
+ config/locales/model.yml
15
+ config/locales/zh-CN.yml
@@ -0,0 +1,18 @@
1
+ #class CnGenerator < Rails::Generators::NamedBase
2
+ class ScaffoldcnGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def generate_scaffoldcn
6
+ templates = [
7
+ 'lib/templates/erb/scaffold/_form.html.erb',
8
+ 'lib/templates/erb/scaffold/edit.html.erb',
9
+ 'lib/templates/erb/scaffold/index.html.erb',
10
+ 'lib/templates/erb/scaffold/new.html.erb',
11
+ 'lib/templates/erb/scaffold/show.html.erb',
12
+ 'config/locales/model.yml',
13
+ 'config/locales/zh-CN.yml']
14
+ templates.each do |path|
15
+ copy_file path, path
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,59 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ zh-CN:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "你的帐户成功激活,现在是登录状态"
7
+ send_instructions: "稍后你将收到帐号激活的电子邮件"
8
+ send_paranoid_instructions: "如果您的邮箱存在于我们的数据库中,您将收到一封找回密码的邮件"
9
+ failure:
10
+ already_authenticated: "您已经登录"
11
+ inactive: "您还没有激活帐户"
12
+ invalid: "邮箱或密码错误"
13
+ invalid_token: "认证码无效"
14
+ locked: "您的帐户已经锁定"
15
+ not_found_in_database: "邮箱或密码错误"
16
+ timeout: "您已登录超时,请重新登录"
17
+ unauthenticated: "继续操作前请注册或者登录"
18
+ unconfirmed: "继续操作前请先激活您的帐号"
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "激活指引"
22
+ reset_password_instructions:
23
+ subject: "重置密码指引"
24
+ unlock_instructions:
25
+ subject: "帐户解锁指引"
26
+ omniauth_callbacks:
27
+ failure: "因为 %{reason},所以您无法从 %{kind} 获得授权"
28
+ success: "成功地从 %{kind} 获得授权"
29
+ passwords:
30
+ no_token: "您似乎不是从一封密码重置邮件来访问这个页面的。如果您确实收到一封密码重置邮件,请确保使用了完整的链接地址。"
31
+ send_instructions: "稍后你将收到帐号激活的电子邮件"
32
+ send_paranoid_instructions: "如果您的邮箱存在于我们的数据库中,您将收到一封解锁账号的邮件"
33
+ updated: "您的密码已修改成功!"
34
+ updated_not_active: "您的密码已修改成功"
35
+ registrations:
36
+ destroyed: "再见!您的帐户已成功注销。我们希望很快可以再见到您"
37
+ signed_up: "欢迎您!您已注册成功!"
38
+ signed_up_but_inactive: "虽然您已经注册成功,但因为你的帐号还未激活,所以你暂时无法登录"
39
+ signed_up_but_locked: "虽然您已经注册成功,但因为你的帐号已被锁定,所以你暂时无法登录"
40
+ signed_up_but_unconfirmed: "带有激活链接的信息已经发送到你的邮箱。请打开此链接来激活你的帐号"
41
+ update_needs_confirmation: "您更改了邮箱地址,我们需要验证您的新邮箱地址,请查看您的邮箱,点击激活链接来验证您的新邮箱地址"
42
+ updated: "您的帐户信息已修改成功!"
43
+ sessions:
44
+ signed_in: "登录成功!"
45
+ signed_out: "注销成功!"
46
+ unlocks:
47
+ send_instructions: "稍后您将收到帐号激活的电子邮件"
48
+ send_paranoid_instructions: "如果您的邮箱存在于我们的数据库中,稍后您会收到一封解锁账号的邮件"
49
+ unlocked: "您的帐号已成功解锁,现在可以登录到系统"
50
+ errors:
51
+ messages:
52
+ already_confirmed: "已经激活,请重新登录"
53
+ confirmation_period_expired: "激活操作必需在 %{period}之前, 您需要提交一份新的申请了"
54
+ expired: "已经过期,请重新提交一份申请"
55
+ not_found: "没有找到"
56
+ not_locked: "未锁定"
57
+ not_saved:
58
+ one: "因为 1 个错误导致此 %{resource}保存失败:"
59
+ other: "因为 %{count}个错误导致此 %{resource}保存失败:"
@@ -0,0 +1,9 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ relation: '联系人'
5
+ attributes:
6
+ relation:
7
+ name: "联系人姓名"
8
+ tel: "电话"
9
+
@@ -0,0 +1,199 @@
1
+ zh-CN:
2
+ date:
3
+ abbr_day_names:
4
+ - 日
5
+ - 一
6
+ - 二
7
+ - 三
8
+ - 四
9
+ - 五
10
+ - 六
11
+ abbr_month_names:
12
+ -
13
+ - 1月
14
+ - 2月
15
+ - 3月
16
+ - 4月
17
+ - 5月
18
+ - 6月
19
+ - 7月
20
+ - 8月
21
+ - 9月
22
+ - 10月
23
+ - 11月
24
+ - 12月
25
+ day_names:
26
+ - 星期日
27
+ - 星期一
28
+ - 星期二
29
+ - 星期三
30
+ - 星期四
31
+ - 星期五
32
+ - 星期六
33
+ formats:
34
+ default: ! '%Y-%m-%d'
35
+ long: ! '%Y年%b%d日'
36
+ short: ! '%b%d日'
37
+ month_names:
38
+ -
39
+ - 一月
40
+ - 二月
41
+ - 三月
42
+ - 四月
43
+ - 五月
44
+ - 六月
45
+ - 七月
46
+ - 八月
47
+ - 九月
48
+ - 十月
49
+ - 十一月
50
+ - 十二月
51
+ order:
52
+ - :year
53
+ - :month
54
+ - :day
55
+ datetime:
56
+ distance_in_words:
57
+ about_x_hours:
58
+ one: 大约一小时
59
+ other: 大约 %{count} 小时
60
+ about_x_months:
61
+ one: 大约一个月
62
+ other: 大约 %{count} 个月
63
+ about_x_years:
64
+ one: 大约一年
65
+ other: 大约 %{count} 年
66
+ almost_x_years:
67
+ one: 接近一年
68
+ other: 接近 %{count} 年
69
+ half_a_minute: 半分钟
70
+ less_than_x_minutes:
71
+ one: 不到一分钟
72
+ other: 不到 %{count} 分钟
73
+ less_than_x_seconds:
74
+ one: 不到一秒
75
+ other: 不到 %{count} 秒
76
+ over_x_years:
77
+ one: 一年多
78
+ other: ! '%{count} 年多'
79
+ x_days:
80
+ one: 一天
81
+ other: ! '%{count} 天'
82
+ x_minutes:
83
+ one: 一分钟
84
+ other: ! '%{count} 分钟'
85
+ x_months:
86
+ one: 一个月
87
+ other: ! '%{count} 个月'
88
+ x_seconds:
89
+ one: 一秒
90
+ other: ! '%{count} 秒'
91
+ prompts:
92
+ day: 日
93
+ hour: 时
94
+ minute: 分
95
+ month: 月
96
+ second: 秒
97
+ year: 年
98
+ errors: &errors
99
+ format: ! '%{attribute} %{message}'
100
+ messages:
101
+ accepted: 必须是可被接受的
102
+ blank: 不能为空字符
103
+ confirmation: 与确认值不匹配
104
+ empty: 不能留空
105
+ equal_to: 必须等于 %{count}
106
+ even: 必须为双数
107
+ exclusion: 是保留关键字
108
+ greater_than: 必须大于 %{count}
109
+ greater_than_or_equal_to: 必须大于或等于 %{count}
110
+ inclusion: 不包含于列表中
111
+ invalid: 是无效的
112
+ less_than: 必须小于 %{count}
113
+ less_than_or_equal_to: 必须小于或等于 %{count}
114
+ not_a_number: 不是数字
115
+ not_an_integer: 必须是整数
116
+ odd: 必须为单数
117
+ record_invalid: ! '验证失败: %{errors}'
118
+ taken: 已经被使用
119
+ too_long: 过长(最长为 %{count} 个字符)
120
+ too_short: 过短(最短为 %{count} 个字符)
121
+ wrong_length: 长度非法(必须为 %{count} 个字符)
122
+ template:
123
+ body: 如下字段出现错误:
124
+ header:
125
+ one: 有 1 个错误发生导致「%{model}」无法被保存。
126
+ other: 有 %{count} 个错误发生导致「%{model}」无法被保存。
127
+ helpers:
128
+ select:
129
+ prompt: 请选择
130
+ submit:
131
+ create: 新增%{model}
132
+ submit: 储存%{model}
133
+ update: 更新%{model}
134
+ number:
135
+ currency:
136
+ format:
137
+ delimiter: ! ','
138
+ format: ! '%u %n'
139
+ precision: 2
140
+ separator: .
141
+ significant: false
142
+ strip_insignificant_zeros: false
143
+ unit: CN¥
144
+ format:
145
+ delimiter: ! ','
146
+ precision: 3
147
+ separator: .
148
+ significant: false
149
+ strip_insignificant_zeros: false
150
+ human:
151
+ decimal_units:
152
+ format: ! '%n %u'
153
+ units:
154
+ billion: 十亿
155
+ million: 百万
156
+ quadrillion: 千兆
157
+ thousand: 千
158
+ trillion: 兆
159
+ unit: ''
160
+ format:
161
+ delimiter: ''
162
+ precision: 1
163
+ significant: false
164
+ strip_insignificant_zeros: false
165
+ storage_units:
166
+ format: ! '%n %u'
167
+ units:
168
+ byte:
169
+ one: Byte
170
+ other: Bytes
171
+ gb: GB
172
+ kb: KB
173
+ mb: MB
174
+ tb: TB
175
+ percentage:
176
+ format:
177
+ delimiter: ''
178
+ precision:
179
+ format:
180
+ delimiter: ''
181
+ support:
182
+ array:
183
+ last_word_connector: ! ', 和 '
184
+ two_words_connector: ! ' 和 '
185
+ words_connector: ! ', '
186
+ time:
187
+ am: 上午
188
+ formats:
189
+ default: ! '%Y年%b%d日 %A %H:%M:%S %Z'
190
+ long: ! '%Y年%b%d日 %H:%M'
191
+ short: ! '%b%d日 %H:%M'
192
+ pm: 下午
193
+ # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
194
+ activemodel:
195
+ errors:
196
+ <<: *errors
197
+ activerecord:
198
+ errors:
199
+ <<: *errors
@@ -0,0 +1,37 @@
1
+ <%%= form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%% if @<%= singular_table_name %>.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
5
+
6
+ <ul>
7
+ <%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
8
+ <li><%%= msg %></li>
9
+ <%% end %>
10
+ </ul>
11
+ </div>
12
+ <%% end %>
13
+
14
+ <% attributes.each do |attribute| -%>
15
+ <div class="field">
16
+ <% if attribute.password_digest? -%>
17
+ <%%= f.label :password %><br>
18
+ <%%= f.password_field :password %>
19
+ </div>
20
+ <div>
21
+ <%%= f.label :password_confirmation %><br>
22
+ <%%= f.password_field :password_confirmation %>
23
+ <% else -%>
24
+ <%- if attribute.reference? -%>
25
+ <%%= f.label :<%= attribute.column_name %> %><br>
26
+ <%%= f.<%= attribute.field_type %> :<%= attribute.column_name %> %>
27
+ <%- else -%>
28
+ <%%= f.label :<%= attribute.name %> %><br>
29
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
30
+ <%- end -%>
31
+ <% end -%>
32
+ </div>
33
+ <% end -%>
34
+ <div class="actions">
35
+ <%%= f.submit '提交'%>
36
+ </div>
37
+ <%% end %>
@@ -0,0 +1,6 @@
1
+ <h1>编辑 <%%= <%= human_name %>.model_name.human %></h1>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to '显示', @<%= singular_table_name %> %> |
6
+ <%%= link_to '返回', <%= index_helper %>_path %>
@@ -0,0 +1,29 @@
1
+ <h1><%%= <%= human_name %>.model_name.human %>列表</h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
7
+ <th><%%= <%= human_name %>.human_attribute_name("<%= attribute.name %>") %></th>
8
+ <% end -%>
9
+ <th colspan="3"></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
15
+ <tr>
16
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
17
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
18
+ <% end -%>
19
+ <td><%%= link_to '显示', <%= singular_table_name %> %></td>
20
+ <td><%%= link_to '编辑', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
21
+ <td><%%= link_to '删除', <%= singular_table_name %>, method: :delete, data: { confirm: '确定删除吗?' } %></td>
22
+ </tr>
23
+ <%% end %>
24
+ </tbody>
25
+ </table>
26
+
27
+ <br>
28
+
29
+ <%%= link_to ('新增' + <%= human_name %>.model_name.human), new_<%= singular_table_name %>_path %>