ad_space 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ac5c4cef041d823408607e595fa2d09307ed6b500d5853a4b59bfba9ff7d171
4
- data.tar.gz: 7146c08caad9d0f6e500082bd0f7ed32c1fa1f1ba63e5b2790738cfaaa41fddf
3
+ metadata.gz: f5fd64d01bfc45cc173f1e95fbaea9b6ac23291e37feb5c072f7f9477bb651ce
4
+ data.tar.gz: 21c7b3e8506219e0bf6f6ad2c979b1ee2de5d71cb56d4804b8948cfebc958d64
5
5
  SHA512:
6
- metadata.gz: b2b0682b020513309c1020df4102877a05551968f24a3d3158f35cdf7f2041756ad8bb13f3fec6f6effd99269c7271601954c266bd87c8e495c8df792b5ddd6f
7
- data.tar.gz: 24cf681247a8988b43d69c00636d4d55c8840d61c2391c0f1767db587796e6a67eb1ac4e77033ef7e0dad5dc1adbcc32597c630cdbb7bc992bd46f5aca7c9643
6
+ metadata.gz: c8e5f37efeaf85765b65ae4c5d487fec4df002bbcc5074edaa1501fe88c80daf2c30092ec2b44265473dc1b6b8bdafb723539321e4c85afa2f304cfd52d9665b
7
+ data.tar.gz: 5bb47c04044cf966c4a7b6f65a98213a9e61cb61ad2bffd2ac689f67f726f8f69bec23cf3c591babcc7c2f9622bc6a60684674cf14461cf9fb0a234a07dfa93a
data/Gemfile CHANGED
@@ -19,4 +19,6 @@ gem 'stimulus-rails'
19
19
 
20
20
  group :development do
21
21
  gem "pg"
22
+
23
+ gem "i18n-tasks"
22
24
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ad_space (0.1.5)
4
+ ad_space (0.1.6)
5
5
  active_model_serializers
6
6
  dotenv-rails
7
7
  rails (>= 7.1.1)
@@ -88,7 +88,15 @@ GEM
88
88
  minitest (>= 5.1)
89
89
  mutex_m
90
90
  tzinfo (~> 2.0)
91
+ ast (2.4.2)
91
92
  base64 (0.1.1)
93
+ better_html (2.0.2)
94
+ actionview (>= 6.0)
95
+ activesupport (>= 6.0)
96
+ ast (~> 2.0)
97
+ erubi (~> 1.4)
98
+ parser (>= 2.4)
99
+ smart_properties
92
100
  bigdecimal (3.1.4)
93
101
  builder (3.2.4)
94
102
  case_transform (0.2)
@@ -111,8 +119,20 @@ GEM
111
119
  erubi (1.12.0)
112
120
  globalid (1.2.1)
113
121
  activesupport (>= 6.1)
122
+ highline (2.1.0)
114
123
  i18n (1.14.1)
115
124
  concurrent-ruby (~> 1.0)
125
+ i18n-tasks (1.0.13)
126
+ activesupport (>= 4.0.2)
127
+ ast (>= 2.1.0)
128
+ better_html (>= 1.0, < 3.0)
129
+ erubi
130
+ highline (>= 2.0.0)
131
+ i18n
132
+ parser (>= 3.2.2.1)
133
+ rails-i18n
134
+ rainbow (>= 2.2.2, < 4.0)
135
+ terminal-table (>= 1.5.1)
116
136
  io-console (0.6.0)
117
137
  irb (1.8.3)
118
138
  rdoc
@@ -146,6 +166,9 @@ GEM
146
166
  racc (~> 1.4)
147
167
  nokogiri (1.15.4-x86_64-linux)
148
168
  racc (~> 1.4)
169
+ parser (3.2.2.4)
170
+ ast (~> 2.4.1)
171
+ racc
149
172
  pg (1.5.4)
150
173
  psych (5.1.1.1)
151
174
  stringio
@@ -181,6 +204,9 @@ GEM
181
204
  rails-html-sanitizer (1.6.0)
182
205
  loofah (~> 2.21)
183
206
  nokogiri (~> 1.14)
207
+ rails-i18n (7.0.8)
208
+ i18n (>= 0.7, < 2)
209
+ railties (>= 6.0.0, < 8)
184
210
  railties (7.1.1)
185
211
  actionpack (= 7.1.1)
186
212
  activesupport (= 7.1.1)
@@ -189,12 +215,14 @@ GEM
189
215
  rake (>= 12.2)
190
216
  thor (~> 1.0, >= 1.2.2)
191
217
  zeitwerk (~> 2.6)
218
+ rainbow (3.1.1)
192
219
  rake (13.0.6)
193
220
  rdoc (6.5.0)
194
221
  psych (>= 4.0.0)
195
222
  reline (0.3.9)
196
223
  io-console (~> 0.5)
197
224
  ruby2_keywords (0.0.5)
225
+ smart_properties (1.17.0)
198
226
  sprockets (4.2.1)
199
227
  concurrent-ruby (~> 1.0)
200
228
  rack (>= 2.2.4, < 4)
@@ -207,6 +235,8 @@ GEM
207
235
  stimulus-rails (1.3.0)
208
236
  railties (>= 6.0.0)
209
237
  stringio (3.0.8)
238
+ terminal-table (3.0.2)
239
+ unicode-display_width (>= 1.1.1, < 3)
210
240
  thor (1.3.0)
211
241
  timeout (0.4.0)
212
242
  turbo-rails (1.5.0)
@@ -215,6 +245,7 @@ GEM
215
245
  railties (>= 6.0.0)
216
246
  tzinfo (2.0.6)
217
247
  concurrent-ruby (~> 1.0)
248
+ unicode-display_width (2.5.0)
218
249
  webrick (1.8.1)
219
250
  websocket-driver (0.7.6)
220
251
  websocket-extensions (>= 0.1.0)
@@ -229,6 +260,7 @@ DEPENDENCIES
229
260
  ad_space!
230
261
  cssbundling-rails
231
262
  debug (>= 1.0.0)
263
+ i18n-tasks
232
264
  jsbundling-rails
233
265
  pg
234
266
  puma
@@ -6,22 +6,25 @@ module AdSpace
6
6
  def index
7
7
  @advertisements = Advertisement.all
8
8
 
9
- add_breadcrumb("Home", root_path)
9
+ add_breadcrumb(t("home"), root_path)
10
10
  end
11
11
 
12
12
  # GET /advertisements/1
13
13
  def show
14
- add_breadcrumb("Home", root_path)
15
- add_breadcrumb("Advertisements", advertisements_path)
14
+ add_breadcrumb(t("home"), root_path)
15
+ add_breadcrumb(t("advertisements"), advertisements_path)
16
16
  end
17
17
 
18
18
  # GET /advertisements/new
19
19
  def new
20
20
  @advertisement = Advertisement.new
21
+
22
+ add_breadcrumb(t("home"), root_path)
21
23
  end
22
24
 
23
25
  # GET /advertisements/1/edit
24
26
  def edit
27
+ add_breadcrumb(t("home"), root_path)
25
28
  end
26
29
 
27
30
  # POST /advertisements
@@ -2,6 +2,27 @@ class AdSpace::Api::V1::AdvertisementsController < ActionController::API
2
2
  # before_action :prepare_params!, only: %w[index]
3
3
 
4
4
  def index
5
+ builder = AdSpace::Advertisement.includes(:slot).where(platform: params[:platform])
6
+ builder = builder.published.unexpired
7
+ builder = builder.where(slot_id: params[:slot_ids].split(",")) unless params[:slot_ids].blank?
8
+
9
+ # TODO: 动态可配置,不同项目可以自定义特殊的查询条件,基于builder
10
+ # 0. 判断是否有配置动态用户信息,proc
11
+ # 1. 通过token获取用户信息 proc
12
+ # 2. 通过用户信息判断用户是否为会员
13
+ # 3. 如果是会员,则不展示广告位为“开屏广告”的广告
14
+ # 4. 如果不是会员,则展示所有广告
15
+ # 5. 如果没有配置动态用户信息,则展示所有广告
16
+ # has_paid 开屏逻辑、member 逻辑
17
+ # token = ApiKey.get_token(params[:token])
18
+ # if token.present?
19
+ # current_user = token.user
20
+ # if current_user && current_user&.paid?
21
+ # # 写死 slot_id
22
+ # builder = builder.where.not(position_code: '10003')
23
+ # end
24
+ # end
25
+
5
26
  width = params[:screen_width].to_f
6
27
  height = params[:screen_height].to_f
7
28
  screen_ratio = width.zero? ? 0 : height / width
@@ -13,15 +34,6 @@ class AdSpace::Api::V1::AdvertisementsController < ActionController::API
13
34
  "large"
14
35
  end
15
36
 
16
- builder = AdSpace::Advertisement.includes(:slot).where(platform: params[:platform])
17
- builder = builder.published.unexpired
18
- builder = builder.where(slot_id: params[:slot_ids].split(",")) unless params[:slot_ids].blank?
19
-
20
- # TODO: 动态可配置,不同项目可以自定义特殊的查询条件,基于builder
21
- # if current_user && current_user&.is_member?
22
- # builder = builder.where.not(position_code: '10003')
23
- # end
24
-
25
37
  unless params[:version_code].blank?
26
38
  array = [0]
27
39
  array.push(params[:version_code].to_i)
@@ -1,6 +1,7 @@
1
1
  module AdSpace
2
2
  class ApplicationController < ActionController::Base
3
3
  helper_method :_current_user
4
+ around_action :use_ad_space_locale
4
5
 
5
6
  before_action :init_app
6
7
 
@@ -26,5 +27,38 @@ module AdSpace
26
27
  def add_breadcrumb(name, path = nil)
27
28
  breadcrumbs << AdSpace::Breadcrumb.new(name, path)
28
29
  end
30
+
31
+ private
32
+
33
+ def default_url_options(options = {})
34
+ { locale: I18n.locale }.merge(options)
35
+ end
36
+
37
+ def use_ad_space_locale(&action)
38
+ @original_i18n_config = I18n.config
39
+ I18n.config = ::AdSpace::I18nConfig.new
40
+ I18n.with_locale(current_locale, &action)
41
+ ensure
42
+ I18n.config = @original_i18n_config
43
+ @original_i18n_config = nil
44
+ end
45
+
46
+ def use_original_locale
47
+ prev_config = I18n.config
48
+ I18n.config = @original_i18n_config if @original_i18n_config
49
+ yield
50
+ ensure
51
+ I18n.config = prev_config
52
+ end
53
+
54
+ def current_locale
55
+ if request.GET['locale']
56
+ request.GET['locale']
57
+ elsif params[:locale]
58
+ params[:locale]
59
+ else
60
+ I18n.default_locale
61
+ end
62
+ end
29
63
  end
30
64
  end
@@ -6,22 +6,25 @@ module AdSpace
6
6
  def index
7
7
  @slots = Slot.all
8
8
 
9
- add_breadcrumb("Home", root_path)
9
+ add_breadcrumb(t("home"), root_path)
10
10
  end
11
11
 
12
12
  # GET /slots/1
13
13
  def show
14
- add_breadcrumb("Home", root_path)
15
- add_breadcrumb("Slots", slots_path)
14
+ add_breadcrumb(t("home"), root_path)
15
+ add_breadcrumb(t("slots"), slots_path)
16
16
  end
17
17
 
18
18
  # GET /slots/new
19
19
  def new
20
20
  @slot = Slot.new
21
+
22
+ add_breadcrumb(t("home"), root_path)
21
23
  end
22
24
 
23
25
  # GET /slots/1/edit
24
26
  def edit
27
+ add_breadcrumb(t("home"), root_path)
25
28
  end
26
29
 
27
30
  # POST /slots
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AdSpace
4
+ class I18nConfig < ::I18n::Config
5
+ BACKEND = I18n::Backend::Simple.new
6
+ AVAILABLE_LOCALES = AdSpace::Engine.root.join("config/locales").glob("*.yml").map { |path| File.basename(path, ".yml").to_sym }.uniq
7
+ AVAILABLE_LOCALES_SET = AVAILABLE_LOCALES.inject(Set.new) { |set, locale| set << locale.to_s << locale.to_sym }
8
+
9
+ def backend
10
+ BACKEND
11
+ end
12
+
13
+ def available_locales
14
+ AVAILABLE_LOCALES
15
+ end
16
+
17
+ def available_locales_set
18
+ AVAILABLE_LOCALES_SET
19
+ end
20
+
21
+ def default_locale
22
+ AdSpace.configuration.dashboard_default_locale
23
+ end
24
+ end
25
+ end
@@ -55,21 +55,6 @@
55
55
  <%= advertisement.remark %>
56
56
  </p>
57
57
 
58
- <p>
59
- <strong>Pv count:</strong>
60
- <%= advertisement.pv_count %>
61
- </p>
62
-
63
- <p>
64
- <strong>Uv count:</strong>
65
- <%= advertisement.uv_count %>
66
- </p>
67
-
68
- <p>
69
- <strong>Click count:</strong>
70
- <%= advertisement.click_count %>
71
- </p>
72
-
73
58
  <% if advertisement.cover_sm.attached? %>
74
59
  <p>
75
60
  <strong>Small Cover Image:</strong>
@@ -13,7 +13,7 @@
13
13
 
14
14
  <div>
15
15
  <%= form.label :platform, style: "display: block" %>
16
- <%= form.select :platform, AdSpace::Advertisement.platforms.keys.map { |platform| [platform.capitalize, platform] } %>
16
+ <%= form.select :platform, AdSpace::Advertisement.platforms.keys.map { |platform| [t("activerecord.enums.ad_space/advertisement.platform.#{platform}"), platform] } %>
17
17
  </div>
18
18
 
19
19
  <div>
@@ -22,7 +22,7 @@
22
22
  </div>
23
23
 
24
24
  <div>
25
- <%= form.label :slot_id, "Slot", style: "display: block" %>
25
+ <%= form.label :slot_id, style: "display: block" %>
26
26
  <%= form.select :slot_id, options_for_select(
27
27
  AdSpace::Slot.all.map { |s| [s.name, s.id, data: { is_splash: s.splash? }] },
28
28
  advertisement.slot_id,
@@ -31,7 +31,7 @@
31
31
 
32
32
  <div>
33
33
  <%= form.label :visibility, style: "display: block" %>
34
- <%= form.select :visibility, AdSpace::Advertisement.visibilities.keys.map { |key| [key.humanize, key] } %>
34
+ <%= form.select :visibility, AdSpace::Advertisement.visibilities.keys.map { |key| [t("activerecord.enums.ad_space/advertisement.visibility.#{key}"), key] } %>
35
35
  </div>
36
36
 
37
37
  <div>
@@ -52,7 +52,7 @@
52
52
  <div>
53
53
  <%= form.label :ad_type, style: "display: block" %>
54
54
  <%= form.select :ad_type,
55
- AdSpace::Advertisement.ad_types.keys.map { |key| [key.humanize, key] },
55
+ AdSpace::Advertisement.ad_types.keys.map { |key| [t("activerecord.enums.ad_space/advertisement.ad_type.#{key}"), key] },
56
56
  {},
57
57
  data: { hello_target: "adType", action: "hello#handleAdTypeChnage" }
58
58
  %>
@@ -60,7 +60,7 @@
60
60
 
61
61
  <div>
62
62
  <%= form.label :dsp_type, style: "display: block" %>
63
- <%= form.select :dsp_type, AdSpace::Advertisement.dsp_types.keys.map { |key| [key.humanize, key] } %>
63
+ <%= form.select :dsp_type, AdSpace::Advertisement.dsp_types.keys.map { |key| [t("activerecord.enums.ad_space/advertisement.dsp_type.#{key}"), key] } %>
64
64
  </div>
65
65
 
66
66
  <div data-hello-target="schemeUrl">
@@ -88,7 +88,7 @@
88
88
 
89
89
  <div data-hello-target="splashUiType">
90
90
  <%= form.label :splash_ui_type, style: "display: block" %>
91
- <%= form.select :splash_ui_type, AdSpace::Advertisement.splash_ui_types.keys.map { |key| [key.humanize, key] } %>
91
+ <%= form.select :splash_ui_type, AdSpace::Advertisement.splash_ui_types.keys.map { |key| [t("activerecord.enums.ad_space/advertisement.splash_ui_type.#{key}"), key] } %>
92
92
  </div>
93
93
 
94
94
  <div data-hello-target="smCover" data-controller="image-upload", data-image-upload-url-value=<%= !advertisement.persisted? ? '' : remove_cover_advertisement_path(advertisement, size: "sm")%>>
@@ -1,10 +1,10 @@
1
- <h1>Editing advertisement</h1>
1
+ <h1><%= t("edit") %></h1>
2
2
 
3
3
  <%= render "form", advertisement: @advertisement %>
4
4
 
5
5
  <br>
6
6
 
7
7
  <div>
8
- <%= link_to "Show this advertisement", @advertisement %> |
9
- <%= link_to "Back to advertisements", advertisements_path %>
8
+ <%= link_to t("show"), @advertisement %> |
9
+ <%= link_to t("back_to"), advertisements_path %>
10
10
  </div>
@@ -1,15 +1,15 @@
1
1
  <p style="color: green"><%= notice %></p>
2
2
 
3
- <h1>Advertisements</h1>
3
+ <h1><%= t("advertisements") %></h1>
4
4
 
5
5
  <div id="advertisements">
6
6
  <% @advertisements.each do |advertisement| %>
7
7
  <%= render advertisement %>
8
8
  <p>
9
- <%= link_to "Show this advertisement", advertisement %>
9
+ <%= link_to t("show"), advertisement %>
10
10
  </p>
11
11
 
12
12
  <% end %>
13
13
  </div>
14
14
 
15
- <%= link_to "New advertisement", new_advertisement_path %>
15
+ <%= link_to t("new"), new_advertisement_path %>
@@ -1,9 +1,9 @@
1
- <h1>New advertisement</h1>
1
+ <h1><%= t("new") %></h1>
2
2
 
3
3
  <%= render "form", advertisement: @advertisement %>
4
4
 
5
5
  <br>
6
6
 
7
7
  <div>
8
- <%= link_to "Back to advertisements", advertisements_path %>
8
+ <%= link_to t("back_to"), advertisements_path %>
9
9
  </div>
@@ -3,11 +3,11 @@
3
3
  <%= render @advertisement %>
4
4
 
5
5
  <div>
6
- <%= link_to "Edit this advertisement", edit_advertisement_path(@advertisement) %> |
7
- <%= link_to "Back to advertisements", advertisements_path %>
8
- <%= button_to "#{@advertisement.published? ? 'Unpublish' : 'Publish'} this advertisement", publish_advertisement_path(@advertisement) %>
9
- <%= button_to "#{@advertisement.archived? ? 'Unarchive' : 'Archive'} this advertisement", archive_advertisement_path(@advertisement) %>
6
+ <%= link_to t("edit"), edit_advertisement_path(@advertisement) %> |
7
+ <%= link_to t("back_to"), advertisements_path %>
8
+ <%= button_to "#{@advertisement.published? ? t("unpublish") : t("publish")}", publish_advertisement_path(@advertisement) %>
9
+ <%= button_to "#{@advertisement.archived? ? t("unarchive") : t("archive")}", archive_advertisement_path(@advertisement) %>
10
10
 
11
11
  <br/>
12
- <%= button_to "Destroy this advertisement", @advertisement, method: :delete %>
12
+ <%= button_to t("destroy"), @advertisement, method: :delete %>
13
13
  </div>
@@ -1,7 +1,7 @@
1
1
  <h1>📺 AdSpace</h1>
2
2
  <ul>
3
- <li><%= link_to "广告", advertisements_path %></li>
4
- <li><%= link_to "位置", slots_path %></li>
5
- <li><%= link_to "Github", "https://github.com/42up/ad_space" %></li>
6
- <li><%= link_to "Doc", "https://github.com/42up/ad_space/blob/main/README.md" %></li>
3
+ <li><%= link_to t("slots"), slots_path %></li>
4
+ <li><%= link_to t("advertisements"), advertisements_path %></li>
5
+ <li><%= link_to t("github"), "https://github.com/42up/ad_space" %></li>
6
+ <li><%= link_to t("doc"), "https://github.com/42up/ad_space/blob/main/README.md" %></li>
7
7
  </ul>
@@ -22,19 +22,19 @@
22
22
  </div>
23
23
 
24
24
  <div data-controller="image-upload", data-image-upload-url-value=<%= !slot.persisted? ? '' : remove_demo_slot_path(slot) %>>
25
- <%= form.label :demo, "Demo", style: "display: block" %>
25
+ <%= form.label :demo, style: "display: block" %>
26
26
  <%= form.file_field :demo, data: {image_upload_target: "input"} %>
27
27
  <% if slot.demo.attached? %>
28
28
  <%= image_tag slot.demo.url, style: "max-width: 200px; height: auto;", data: {image_upload_target: "preview"} %>
29
- <button type="button" data-image-upload-target="removeButton">移除图片</button>
29
+ <button type="button" data-image-upload-target="removeButton"><%= t("remove_image") %></button>
30
30
  <% else %>
31
31
  <img data-image-upload-target="preview" style="max-width: 200px; height: auto;">
32
- <button type="button" data-image-upload-target="removeButton" style="display: none;">移除图片</button>
32
+ <button type="button" data-image-upload-target="removeButton" style="display: none;"><%= t("remove_image") %></button>
33
33
  <% end %>
34
34
  </div>
35
35
 
36
36
  <div>
37
- <%= form.label :is_splash, "Is Splash" %>
37
+ <%= form.label :is_splash %>
38
38
  <%= form.check_box :is_splash, { checked: form.object.is_splash } %>
39
39
  </div>
40
40
 
@@ -1,27 +1,27 @@
1
1
  <div id="<%= dom_id slot %>">
2
2
  <p>
3
- <strong>Name:</strong>
3
+ <strong><%= AdSpace::Slot.human_attribute_name(:name) %>:</strong>
4
4
  <%= slot.name %>
5
5
  </p>
6
6
 
7
7
  <p>
8
- <strong>Uuid:</strong>
8
+ <strong><%= AdSpace::Slot.human_attribute_name(:uuid) %>:</strong>
9
9
  <%= slot.uuid %>
10
10
  </p>
11
11
 
12
12
  <p>
13
- <strong>Remark:</strong>
13
+ <strong><%= AdSpace::Slot.human_attribute_name(:remark) %>:</strong>
14
14
  <%= slot.remark %>
15
15
  </p>
16
16
 
17
17
  <p>
18
- <strong>Is Splash:</strong>
18
+ <strong><%= AdSpace::Slot.human_attribute_name(:is_splash) %>:</strong>
19
19
  <%= slot.is_splash %>
20
20
  </p>
21
21
 
22
22
  <% if slot.demo.attached? %>
23
23
  <p>
24
- <strong>Demo:</strong>
24
+ <strong><%= AdSpace::Slot.human_attribute_name(:demo) %>:</strong>
25
25
  <%= image_tag slot.demo.url, style: "max-width: 200px; height: auto;" %>
26
26
  </p>
27
27
  <% end %>
@@ -1,10 +1,10 @@
1
- <h1>Editing slot</h1>
1
+ <h1><%= t("edit") %></h1>
2
2
 
3
3
  <%= render "form", slot: @slot %>
4
4
 
5
5
  <br>
6
6
 
7
7
  <div>
8
- <%= link_to "Show this slot", @slot %> |
9
- <%= link_to "Back to slots", slots_path %>
8
+ <%= link_to t("show"), @slot %> |
9
+ <%= link_to t("back_to"), slots_path %>
10
10
  </div>
@@ -1,14 +1,14 @@
1
1
  <p style="color: green"><%= notice %></p>
2
2
 
3
- <h1>Slots</h1>
3
+ <h1><%= t("slots") %></h1>
4
4
 
5
5
  <div id="slots">
6
6
  <% @slots.each do |slot| %>
7
7
  <%= render slot %>
8
8
  <p>
9
- <%= link_to "Show this slot", slot %>
9
+ <%= link_to t("show"), slot %>
10
10
  </p>
11
11
  <% end %>
12
12
  </div>
13
13
 
14
- <%= link_to "New slot", new_slot_path %>
14
+ <%= link_to t("new"), new_slot_path %>
@@ -1,9 +1,9 @@
1
- <h1>New slot</h1>
1
+ <h1><%= t("new") %></h1>
2
2
 
3
3
  <%= render "form", slot: @slot %>
4
4
 
5
5
  <br>
6
6
 
7
7
  <div>
8
- <%= link_to "Back to slots", slots_path %>
8
+ <%= link_to t("back_to"), slots_path %>
9
9
  </div>
@@ -3,8 +3,8 @@
3
3
  <%= render @slot %>
4
4
 
5
5
  <div>
6
- <%= link_to "Edit this slot", edit_slot_path(@slot) %> |
7
- <%= link_to "Back to slots", slots_path %>
6
+ <%= link_to t("edit"), edit_slot_path(@slot) %> |
7
+ <%= link_to t("back_to"), slots_path %>
8
8
 
9
- <%= button_to "Destroy this slot", @slot, method: :delete %>
9
+ <%= button_to t("destroy"), @slot, method: :delete %>
10
10
  </div>
@@ -0,0 +1,155 @@
1
+ # i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
2
+
3
+ # The "main" locale.
4
+ base_locale: zh-CN
5
+ ## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
6
+ # locales: [es, fr]
7
+ ## Reporting locale, default: en. Available: en, ru.
8
+ # internal_locale: en
9
+
10
+ # Read and write translations.
11
+ data:
12
+ ## Translations are read from the file system. Supported format: YAML, JSON.
13
+ ## Provide a custom adapter:
14
+ # adapter: I18n::Tasks::Data::FileSystem
15
+
16
+ # Locale files or `Find.find` patterns where translations are read from:
17
+ read:
18
+ ## Default:
19
+ # - config/locales/%{locale}.yml
20
+ ## More files:
21
+ # - config/locales/**/*.%{locale}.yml
22
+
23
+ # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
24
+ # `i18n-tasks normalize -p` will force move the keys according to these rules
25
+ write:
26
+ ## For example, write devise and simple form keys to their respective files:
27
+ # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
28
+ ## Catch-all default:
29
+ # - config/locales/%{locale}.yml
30
+
31
+ # External locale data (e.g. gems).
32
+ # This data is not considered unused and is never written to.
33
+ external:
34
+ ## Example (replace %#= with %=):
35
+ # - "<%#= %x[bundle info vagrant --path].chomp %>/templates/locales/%{locale}.yml"
36
+
37
+ ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
38
+ # router: conservative_router
39
+
40
+ yaml:
41
+ write:
42
+ # do not wrap lines at 80 characters
43
+ line_width: -1
44
+
45
+ ## Pretty-print JSON:
46
+ # json:
47
+ # write:
48
+ # indent: ' '
49
+ # space: ' '
50
+ # object_nl: "\n"
51
+ # array_nl: "\n"
52
+
53
+ # Find translate calls
54
+ search:
55
+ ## Paths or `Find.find` patterns to search in:
56
+ # paths:
57
+ # - app/
58
+
59
+ ## Root directories for relative keys resolution.
60
+ # relative_roots:
61
+ # - app/controllers
62
+ # - app/helpers
63
+ # - app/mailers
64
+ # - app/presenters
65
+ # - app/views
66
+
67
+ ## Directories where method names which should not be part of a relative key resolution.
68
+ # By default, if a relative translation is used inside a method, the name of the method will be considered part of the resolved key.
69
+ # Directories listed here will not consider the name of the method part of the resolved key
70
+ #
71
+ # relative_exclude_method_name_paths:
72
+ # -
73
+
74
+ ## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
75
+ ## *.jpg *.jpeg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
76
+ ## *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus *.webp *.map *.xlsx
77
+ exclude:
78
+ - app/assets/images
79
+ - app/assets/fonts
80
+ - app/assets/videos
81
+ - app/assets/builds
82
+
83
+ ## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
84
+ ## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
85
+ # only: ["*.rb", "*.html.slim"]
86
+
87
+ ## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
88
+ # strict: true
89
+
90
+ ## Allows adding ast_matchers for finding translations using the AST-scanners
91
+ ## The available matchers are:
92
+ ## - RailsModelMatcher
93
+ ## Matches ActiveRecord translations like
94
+ ## User.human_attribute_name(:email) and User.model_name.human
95
+ ##
96
+ ## To implement your own, please see `I18n::Tasks::Scanners::AstMatchers::BaseMatcher`.
97
+ # <%# I18n::Tasks.add_ast_matcher('I18n::Tasks::Scanners::AstMatchers::RailsModelMatcher') %>
98
+
99
+ ## Multiple scanners can be used. Their results are merged.
100
+ ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
101
+ ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
102
+
103
+ ## Translation Services
104
+ # translation:
105
+ # # Google Translate
106
+ # # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
107
+ # google_translate_api_key: "AbC-dEf5"
108
+ # # DeepL Pro Translate
109
+ # # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro
110
+ # deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A"
111
+ # # deepl_host: "https://api.deepl.com"
112
+ # # deepl_version: "v2"
113
+ # # add additional options to the DeepL.translate call: https://www.deepl.com/docs-api/translate-text/translate-text/
114
+ # deepl_options:
115
+ # formality: prefer_less
116
+ ## Do not consider these keys missing:
117
+ # ignore_missing:
118
+ # - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
119
+ # - '{devise,simple_form}.*'
120
+
121
+ ## Consider these keys used:
122
+ # ignore_unused:
123
+ # - 'activerecord.attributes.*'
124
+ # - '{devise,kaminari,will_paginate}.*'
125
+ # - 'simple_form.{yes,no}'
126
+ # - 'simple_form.{placeholders,hints,labels}.*'
127
+ # - 'simple_form.{error_notification,required}.:'
128
+
129
+ ## Exclude these keys from the `i18n-tasks eq-base' report:
130
+ # ignore_eq_base:
131
+ # all:
132
+ # - common.ok
133
+ # fr,es:
134
+ # - common.brand
135
+
136
+ ## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report:
137
+ # ignore_inconsistent_interpolations:
138
+ # - 'activerecord.attributes.*'
139
+
140
+ ## Ignore these keys completely:
141
+ # ignore:
142
+ # - kaminari.*
143
+
144
+ ## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
145
+ ## e.g. in case of a relative key defined in a helper method.
146
+ ## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
147
+ #
148
+ # <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
149
+ # only: %w(*.html.haml *.html.slim),
150
+ # patterns: [['= title\b', '.page_title']] %>
151
+ #
152
+ # The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
153
+ #
154
+ # <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
155
+ # patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
@@ -0,0 +1,240 @@
1
+ ---
2
+ zh-CN:
3
+ home: 首页
4
+ edit: 编辑
5
+ new: 新建
6
+ back_to: 返回列表
7
+ show: 详情
8
+ destroy: 删除
9
+ remove_image: 移除图片
10
+ slots: 广告位
11
+ advertisements: 广告
12
+ publish: 发布
13
+ unpublish: 撤销发布
14
+ archive: 归档
15
+ unarchive: 撤销归档
16
+ github: Github
17
+ doc: 文档
18
+ activerecord:
19
+ attributes:
20
+ ad_space/slot:
21
+ name: 名称
22
+ uuid: UUID
23
+ remark: 备注
24
+ is_splash: 是否开屏位置?
25
+ demo: 示例图片
26
+ ad_space/advertisement:
27
+ name: 名称
28
+ uuid: UUID
29
+ published_at: 发布时间
30
+ started_at: 生效时间
31
+ ended_at: 失效时间
32
+ platform: 平台
33
+ archived_at: 归档时间
34
+ weight: 权重
35
+ remark: 备注
36
+ ad_type: 广告类型
37
+ visibility: 可见范围
38
+ scheme_url: 跳转地址
39
+ splash_countdown: 开屏倒计时
40
+ splash_ui_type: 开屏样式
41
+ dsp_type: DSP广告类型
42
+ target_version_codes: 目标版本
43
+ slot_id: 广告展示位置
44
+ enums:
45
+ ad_space/advertisement:
46
+ platform:
47
+ ios: 苹果
48
+ android: 安卓
49
+ dsp_type:
50
+ gdt: 广点通
51
+ jrtt: 穿山甲
52
+ google: 谷歌Adsense
53
+ splash_ui_type:
54
+ half: 半屏
55
+ full: 全屏
56
+ ad_type:
57
+ dsp: SDK广告
58
+ custom: 自定义广告
59
+ visibility:
60
+ all: 全部用户
61
+ regular_user: 非付费用户
62
+ premium_member: 付费用户
63
+ errors:
64
+ messages:
65
+ record_invalid: 验证失败:%{errors}
66
+ restrict_dependent_destroy:
67
+ has_one: 由于%{record}需要此记录,所以无法移除记录
68
+ has_many: 由于%{record}需要此记录,所以无法移除记录
69
+ date:
70
+ abbr_day_names:
71
+ - 周日
72
+ - 周一
73
+ - 周二
74
+ - 周三
75
+ - 周四
76
+ - 周五
77
+ - 周六
78
+ abbr_month_names:
79
+ -
80
+ - 1月
81
+ - 2月
82
+ - 3月
83
+ - 4月
84
+ - 5月
85
+ - 6月
86
+ - 7月
87
+ - 8月
88
+ - 9月
89
+ - 10月
90
+ - 11月
91
+ - 12月
92
+ day_names:
93
+ - 星期日
94
+ - 星期一
95
+ - 星期二
96
+ - 星期三
97
+ - 星期四
98
+ - 星期五
99
+ - 星期六
100
+ formats:
101
+ default: "%Y-%m-%d"
102
+ long: "%Y年%m月%d日"
103
+ short: "%m月%d日"
104
+ month_names:
105
+ -
106
+ - 一月
107
+ - 二月
108
+ - 三月
109
+ - 四月
110
+ - 五月
111
+ - 六月
112
+ - 七月
113
+ - 八月
114
+ - 九月
115
+ - 十月
116
+ - 十一月
117
+ - 十二月
118
+ order:
119
+ - :year
120
+ - :month
121
+ - :day
122
+ datetime:
123
+ distance_in_words:
124
+ about_x_hours: 大约%{count}小时
125
+ about_x_months: 大约%{count}个月
126
+ about_x_years: 大约%{count}年
127
+ almost_x_years: 接近%{count}年
128
+ half_a_minute: 半分钟
129
+ less_than_x_seconds: 不到%{count}秒
130
+ less_than_x_minutes: 不到%{count}分钟
131
+ over_x_years: "%{count}年多"
132
+ x_seconds: "%{count}秒"
133
+ x_minutes: "%{count}分钟"
134
+ x_days: "%{count}天"
135
+ x_months: "%{count}个月"
136
+ x_years: "%{count}年"
137
+ prompts:
138
+ second: 秒
139
+ minute: 分
140
+ hour: 时
141
+ day: 日
142
+ month: 月
143
+ year: 年
144
+ errors:
145
+ format: "%{attribute}%{message}"
146
+ messages:
147
+ accepted: 必须是可被接受的
148
+ blank: 不能为空字符
149
+ confirmation: 与%{attribute}不匹配
150
+ empty: 不能留空
151
+ equal_to: 必须等于%{count}
152
+ even: 必须为双数
153
+ exclusion: 是保留关键字
154
+ greater_than: 必须大于%{count}
155
+ greater_than_or_equal_to: 必须大于或等于%{count}
156
+ inclusion: 不包含于列表中
157
+ invalid: 是无效的
158
+ less_than: 必须小于%{count}
159
+ less_than_or_equal_to: 必须小于或等于%{count}
160
+ model_invalid: 验证失败:%{errors}
161
+ not_a_number: 不是数字
162
+ not_an_integer: 必须是整数
163
+ odd: 必须为单数
164
+ other_than: 长度非法(不可为%{count}个字符)
165
+ present: 必须是空白
166
+ required: 必须存在
167
+ taken: 已经被使用
168
+ too_long: 过长(最长为%{count}个字符)
169
+ too_short: 过短(最短为%{count}个字符)
170
+ wrong_length: 长度非法(必须为%{count}个字符)
171
+ template:
172
+ body: 如下字段出现错误:
173
+ header: 有%{count}个错误发生导致“%{model}”无法被保存。
174
+ helpers:
175
+ select:
176
+ prompt: 请选择
177
+ submit:
178
+ create: 新增%{model}
179
+ submit: 储存%{model}
180
+ update: 更新%{model}
181
+ number:
182
+ currency:
183
+ format:
184
+ delimiter: ","
185
+ format: "%u %n"
186
+ precision: 2
187
+ separator: "."
188
+ significant: false
189
+ strip_insignificant_zeros: false
190
+ unit: CN¥
191
+ format:
192
+ delimiter: ","
193
+ precision: 3
194
+ separator: "."
195
+ significant: false
196
+ strip_insignificant_zeros: false
197
+ human:
198
+ decimal_units:
199
+ format: "%n %u"
200
+ units:
201
+ billion: 十亿
202
+ million: 百万
203
+ quadrillion: 千兆
204
+ thousand: 千
205
+ trillion: 兆
206
+ unit: ''
207
+ format:
208
+ delimiter: ''
209
+ precision: 1
210
+ significant: false
211
+ strip_insignificant_zeros: false
212
+ storage_units:
213
+ format: "%n %u"
214
+ units:
215
+ byte: 字节
216
+ eb: EB
217
+ gb: GB
218
+ kb: KB
219
+ mb: MB
220
+ pb: PB
221
+ tb: TB
222
+ percentage:
223
+ format:
224
+ delimiter: ''
225
+ format: "%n%"
226
+ precision:
227
+ format:
228
+ delimiter: ''
229
+ support:
230
+ array:
231
+ last_word_connector: "、"
232
+ two_words_connector: 和
233
+ words_connector: "、"
234
+ time:
235
+ am: 上午
236
+ formats:
237
+ default: "%Y年%m月%d日 %A %H:%M:%S %Z"
238
+ long: "%Y年%m月%d日 %H:%M"
239
+ short: "%m月%d日 %H:%M"
240
+ pm: 下午
@@ -1,12 +1,17 @@
1
1
  module AdSpace
2
2
  class Configuration
3
+ DEFAULT_DASHBOARD_DEFAULT_LOCALE = "zh-CN"
4
+
3
5
  attr_writer :app_name
4
6
  attr_writer :root_path
5
7
  attr_accessor :current_user
8
+ attr_accessor :dashboard_default_locale
9
+
6
10
 
7
11
  def initialize
8
12
  @root_path = "/ad_space"
9
13
  @app_name = ::Rails.application.class.to_s.split("::").first.underscore.humanize(keep_id_suffix: true)
14
+ @dashboard_default_locale = DEFAULT_DASHBOARD_DEFAULT_LOCALE
10
15
  end
11
16
 
12
17
  def current_user_method(&block)
@@ -1,3 +1,3 @@
1
1
  module AdSpace
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ad_space
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - 42up
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-02 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -103,6 +103,7 @@ files:
103
103
  - app/models/ad_space/advertisement.rb
104
104
  - app/models/ad_space/application_record.rb
105
105
  - app/models/ad_space/breadcrumb.rb
106
+ - app/models/ad_space/i18n_config.rb
106
107
  - app/models/ad_space/slot.rb
107
108
  - app/serializers/v1/advertisement_serializer.rb
108
109
  - app/validators/url_or_custom_scheme_validator.rb
@@ -121,6 +122,8 @@ files:
121
122
  - app/views/ad_space/slots/show.html.erb
122
123
  - app/views/layouts/ad_space/application.html.erb
123
124
  - bin/rails
125
+ - config/i18n-tasks.yml
126
+ - config/locales/zh-CN.yml
124
127
  - config/routes.rb
125
128
  - db/migrate/20231026152912_create_ad_space_slots.rb
126
129
  - db/migrate/20231026160758_create_ad_space_advertisements.rb