From 78c62a0633572ba3e5def3989e5fff07f98ff307 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Mon, 13 Jan 2020 17:14:53 +0800 Subject: [PATCH 1/2] add i18n for displaying subtitle / cover image --- app/views/admin/announcements/_form.html.erb | 4 ++-- config/locales/en.yml | 4 +++- config/locales/zh_tw.yml | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/admin/announcements/_form.html.erb b/app/views/admin/announcements/_form.html.erb index 96b6587..62ebf88 100644 --- a/app/views/admin/announcements/_form.html.erb +++ b/app/views/admin/announcements/_form.html.erb @@ -69,7 +69,7 @@
- <%= f.label :display_subtitle, 'display subtitle', :class => "control-label muted" %> + <%= f.label :display_subtitle, t("announcement.display_subtitle"), :class => "control-label muted" %>
<%= f.check_box :display_subtitle %>
@@ -77,7 +77,7 @@
- <%= f.label :display_img, 'display img src', :class => "control-label muted" %> + <%= f.label :display_img, t("announcement.display_img"), :class => "control-label muted" %>
<%= f.check_box :display_img %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 5c2479a..550dd01 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -93,4 +93,6 @@ en: resend_mail: Re-send Email is_external_link: Enable External Link external_link: External Link - external_link_hint: "Make sure URL starts with http://" \ No newline at end of file + external_link_hint: "Make sure URL starts with http://" + display_subtitle: Display Subtitle + display_img: Display Cover Image diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index a64f0fe..5980d73 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -98,3 +98,5 @@ zh_tw: is_external_link: 連結外部網址 external_link: 外部連結 external_link_hint: "確定連結開頭為http://" + display_subtitle: 顯示副標題 + display_img: 顯示圖片 From 0fa05d46c278df5983315c3682a604fd3b17be57 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Mon, 13 Jan 2020 17:24:21 +0800 Subject: [PATCH 2/2] add img_description for front-end --- app/controllers/announcements_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 576e284..7187078 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -340,6 +340,7 @@ class AnnouncementsController < ApplicationController img_src = nil subtitle_ann = announcement.subtitle if announcement.display_subtitle? img_src = (announcement.image.thumb.url || "/assets/announcement-default.jpg") if announcement.display_img? + img_description = announcement.image_description if announcement.image_description.present? { "tags" => tags, @@ -353,6 +354,7 @@ class AnnouncementsController < ApplicationController "body" =>announcement.text, "image" => announcement.image.url, "img_src" => img_src, + "img_description" => img_description, "alt_title" => desc }, "impressionist" => (announcement.is_preview ? nil : announcement),