From 4f24c5ff43235bbc649c4c1388bc51b5d5570377 Mon Sep 17 00:00:00 2001 From: Josh Puetz Date: Thu, 20 Jan 2022 11:47:01 -0600 Subject: [PATCH] Constantize broadcast messages (#16219) --- config/locales/misc/en.yml | 17 ++++ config/locales/misc/fr.yml | 17 ++++ db/seeds.rb | 50 ++++-------- ...sert_facebook_connect_broadcast_message.rb | 5 +- ..._insert_forem_connect_broadcast_message.rb | 5 +- ...oogle_ouauth2_connect_broadcast_message.rb | 5 +- ..._insert_apple_connect_broadcast_message.rb | 5 +- spec/factories/broadcasts.rb | 78 ++++--------------- 8 files changed, 65 insertions(+), 117 deletions(-) diff --git a/config/locales/misc/en.yml b/config/locales/misc/en.yml index 0929a7a8e..e3405b3bc 100644 --- a/config/locales/misc/en.yml +++ b/config/locales/misc/en.yml @@ -3,6 +3,23 @@ en: create_mascot: name: Mascot error: Mascot already set + broadcast: + welcome: + ask_question: "Sloan here! 👋 I noticed that you haven't asked a question yet. Asking a question is easy to do; just click on 'Create Post' in the sidebar of the tag page to get started!" + customize_experience: "Sloan here! 👋 Did you know that that you can customize your DEV experience? Try changing your font and theme and find the best style for you!" + customize_feed: "Hi, it's me again! 👋 Now that you're a part of the DEV community, let's focus on personalizing your content. You can start by following some tags to help customize your feed! 🎉" + discuss_and_ask: "Sloan here! 👋 I noticed that you haven't asked a question or started a discussion yet. It's easy to do both of these; just click on 'Create Post' in the sidebar of the tag page to get started!" + download_app: "Sloan here, with one last tip! 👋 Have you downloaded the DEV mobile app yet? Consider downloading it so you can access all of your favorite DEV content on the go!" + set_up_profile: "Welcome to DEV! 👋 I'm Sloan, the community mascot and I'm here to help get you started. Let's begin by setting up your profile!" + start_discussion: "Sloan here! 👋 I noticed that you haven't started a discussion yet. Starting a discussion is easy to do; just click on 'Create Post' in the sidebar of the tag page to get started!" + welcome_thread: "Sloan here again! 👋 DEV is a friendly community. Why not introduce yourself by leaving a comment in the welcome thread!" + connect: + apple: "You're on a roll! 🎉 Do you have an Apple account? Consider connecting it." + facebook: "You're on a roll! 🎉 Do you have a Facebook account? Consider connecting it." + forem: "You're on a roll! 🎉 Do you have a Forem account? Consider connecting it." + github: "You're on a roll! 🎉 Do you have a GitHub account? Consider connecting it so you can pin any of your repos to your profile." + google: "You're on a roll! 🎉 Do you have a Google account? Consider connecting it." + twitter: "You're on a roll! 🎉 Do you have a Twitter account? Consider connecting it so we can @mention you if we share your post via our Twitter account @thePracticalDev." errors: authentication: errors: diff --git a/config/locales/misc/fr.yml b/config/locales/misc/fr.yml index 950dc1713..6d963eb75 100644 --- a/config/locales/misc/fr.yml +++ b/config/locales/misc/fr.yml @@ -3,6 +3,23 @@ fr: create_mascot: name: Mascot error: Mascot already set + broadcast: + welcome: + ask_question: "Sloan here! 👋 I noticed that you haven't asked a question yet. Asking a question is easy to do; just click on 'Create Post' in the sidebar of the tag page to get started!" + customize_experience: "Sloan here! 👋 Did you know that that you can customize your DEV experience? Try changing your font and theme and find the best style for you!" + customize_feed: "Hi, it's me again! 👋 Now that you're a part of the DEV community, let's focus on personalizing your content. You can start by following some tags to help customize your feed! 🎉" + discuss_and_ask: "Sloan here! 👋 I noticed that you haven't asked a question or started a discussion yet. It's easy to do both of these; just click on 'Create Post' in the sidebar of the tag page to get started!" + download_app: "Sloan here, with one last tip! 👋 Have you downloaded the DEV mobile app yet? Consider downloading it so you can access all of your favorite DEV content on the go!" + set_up_profile: "Welcome to DEV! 👋 I'm Sloan, the community mascot and I'm here to help get you started. Let's begin by setting up your profile!" + start_discussion: "Sloan here! 👋 I noticed that you haven't started a discussion yet. Starting a discussion is easy to do; just click on 'Create Post' in the sidebar of the tag page to get started!" + welcome_thread: "Sloan here again! 👋 DEV is a friendly community. Why not introduce yourself by leaving a comment in the welcome thread!" + connect: + apple: "You're on a roll! 🎉 Do you have an Apple account? Consider connecting it." + facebook: "You're on a roll! 🎉 Do you have a Facebook account? Consider connecting it." + forem: "You're on a roll! 🎉 Do you have a Forem account? Consider connecting it." + github: "You're on a roll! 🎉 Do you have a GitHub account? Consider connecting it so you can pin any of your repos to your profile." + google: "You're on a roll! 🎉 Do you have a Google account? Consider connecting it." + twitter: "You're on a roll! 🎉 Do you have a Twitter account? Consider connecting it so we can @mention you if we share your post via our Twitter account @thePracticalDev." errors: authentication: errors: diff --git a/db/seeds.rb b/db/seeds.rb index ccc70ab40..26a4a9a5a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -358,43 +358,19 @@ end seeder.create_if_none(Broadcast) do broadcast_messages = { - set_up_profile: "Welcome to DEV! 👋 I'm Sloan, the community mascot and I'm here to help get you started. " \ - "Let's begin by setting up your profile!", - welcome_thread: "Sloan here again! 👋 DEV is a friendly community. " \ - "Why not introduce yourself by leaving a comment in the welcome thread!", - twitter_connect: "You're on a roll! 🎉 Do you have a Twitter account? " \ - "Consider connecting it so we can @mention you if we share your post " \ - "via our Twitter account @thePracticalDev.", - facebook_connect: "You're on a roll! 🎉 Do you have a Facebook account? " \ - "Consider connecting it.", - github_connect: "You're on a roll! 🎉 Do you have a GitHub account? " \ - "Consider connecting it so you can pin any of your repos to your profile.", - google_oauth2_connect: "You're on a roll! 🎉 Do you have a Google account? " \ - "Consider connecting it.", - apple_connect: "You're on a roll! 🎉 Do you have an Apple account? " \ - "Consider connecting it.", - customize_feed: - "Hi, it's me again! 👋 Now that you're a part of the DEV community, let's focus on personalizing " \ - "your content. You can start by following some tags to help customize your feed! 🎉", - customize_experience: - "Sloan here! 👋 Did you know that that you can customize your DEV experience? " \ - "Try changing your font and theme and find the best style for you!", - start_discussion: - "Sloan here! 👋 I noticed that you haven't " \ - "started a discussion yet. Starting a discussion is easy to do; " \ - "just click on 'Create Post' in the sidebar of the tag page to get started!", - ask_question: - "Sloan here! 👋 I noticed that you haven't " \ - "asked a question yet. Asking a question is easy to do; " \ - "just click on 'Create Post' in the sidebar of the tag page to get started!", - discuss_and_ask: - "Sloan here! 👋 I noticed that you haven't " \ - "asked a question or " \ - "started a discussion yet. It's easy to do both of these; " \ - "just click on 'Create Post' in the sidebar of the tag page to get started!", - download_app: "Sloan here, with one last tip! 👋 Have you downloaded the DEV mobile app yet? " \ - "Consider downloading it so you can access all " \ - "of your favorite DEV content on the go!" + set_up_profile: I18n.t("broadcast.welcome.set_up_profile"), + welcome_thread: I18n.t("broadcast.welcome.welcome_thread"), + twitter_connect: I18n.t("broadcast.connect.twitter"), + facebook_connect: I18n.t("broadcast.connect.facebook"), + github_connect: I18n.t("broadcast.connect.github"), + google_oauth2_connect: I18n.t("broadcast.connect.google"), + apple_connect: I18n.t("broadcast.connect.apple"), + customize_feed: I18n.t("broadcast.welcome.customize_feed"), + customize_experience: I18n.t("broadcast.welcome.customize_experience"), + start_discussion: I18n.t("broadcast.welcome.start_discussion"), + ask_question: I18n.t("broadcast.welcome.ask_question"), + discuss_and_ask: I18n.t("broadcast.welcome.discuss_and_ask"), + download_app: I18n.t("broadcast.welcome.download_app"), } broadcast_messages.each do |type, message| diff --git a/lib/data_update_scripts/20200820153340_insert_facebook_connect_broadcast_message.rb b/lib/data_update_scripts/20200820153340_insert_facebook_connect_broadcast_message.rb index 34098dbe5..70f780022 100644 --- a/lib/data_update_scripts/20200820153340_insert_facebook_connect_broadcast_message.rb +++ b/lib/data_update_scripts/20200820153340_insert_facebook_connect_broadcast_message.rb @@ -3,12 +3,9 @@ module DataUpdateScripts def run return if Broadcast.find_by title: "Welcome Notification: facebook_connect" - message = "You're on a roll! 🎉 Do you have a Facebook account? " \ - "Consider connecting it." - Broadcast.create!( title: "Welcome Notification: facebook_connect", - processed_html: message, + processed_html: I18n.t("broadcast.connect.facebook"), type_of: "Welcome", active: true, ) diff --git a/lib/data_update_scripts/20210921235050_insert_forem_connect_broadcast_message.rb b/lib/data_update_scripts/20210921235050_insert_forem_connect_broadcast_message.rb index 0efb6a6bb..fc40eebf8 100644 --- a/lib/data_update_scripts/20210921235050_insert_forem_connect_broadcast_message.rb +++ b/lib/data_update_scripts/20210921235050_insert_forem_connect_broadcast_message.rb @@ -3,12 +3,9 @@ module DataUpdateScripts def run return if Broadcast.find_by(title: "Welcome Notification: forem_connect") - message = "You're on a roll! 🎉 Do you have a Forem account? " \ - "Consider connecting it." - Broadcast.create!( title: "Welcome Notification: forem_connect", - processed_html: message, + processed_html: I18n.t("broadcast.connect.forem"), type_of: "Welcome", active: true, ) diff --git a/lib/data_update_scripts/20220107215659_insert_google_ouauth2_connect_broadcast_message.rb b/lib/data_update_scripts/20220107215659_insert_google_ouauth2_connect_broadcast_message.rb index a449d908b..375f47816 100644 --- a/lib/data_update_scripts/20220107215659_insert_google_ouauth2_connect_broadcast_message.rb +++ b/lib/data_update_scripts/20220107215659_insert_google_ouauth2_connect_broadcast_message.rb @@ -3,12 +3,9 @@ module DataUpdateScripts def run return if Broadcast.find_by(title: "Welcome Notification: google_oauth2_connect") - message = "You're on a roll! 🎉 Do you have a Google account? " \ - "Consider connecting it." - Broadcast.create!( title: "Welcome Notification: google_oauth2_connect", - processed_html: message, + processed_html: I18n.t("broadcast.connect.google"), type_of: "Welcome", active: true, ) diff --git a/lib/data_update_scripts/20220111192031_insert_apple_connect_broadcast_message.rb b/lib/data_update_scripts/20220111192031_insert_apple_connect_broadcast_message.rb index 31a793731..6ff903932 100644 --- a/lib/data_update_scripts/20220111192031_insert_apple_connect_broadcast_message.rb +++ b/lib/data_update_scripts/20220111192031_insert_apple_connect_broadcast_message.rb @@ -4,12 +4,9 @@ module DataUpdateScripts title = "Welcome Notification: apple_connect" return if Broadcast.find_by title: title - message = "You're on a roll! 🎉 Do you have an Apple account? " \ - "Consider connecting it." - Broadcast.create!( title: title, - processed_html: message, + processed_html: I18n.t("broadcast.connect.apple"), type_of: "Welcome", active: true, ) diff --git a/spec/factories/broadcasts.rb b/spec/factories/broadcasts.rb index be4c80b93..0a3afb251 100644 --- a/spec/factories/broadcasts.rb +++ b/spec/factories/broadcasts.rb @@ -6,135 +6,85 @@ FactoryBot.define do factory :set_up_profile_broadcast do title { "Welcome Notification: set_up_profile" } type_of { "Welcome" } - processed_html do - "Welcome to DEV! 👋 I'm Sloan, " \ - "the community mascot and I'm here to help get you started. " \ - "Let's begin by setting up your profile!" - end + processed_html { I18n.t("broadcast.welcome.set_up_profile") } end factory :welcome_broadcast do title { "Welcome Notification: welcome_thread" } type_of { "Welcome" } - processed_html do - "Sloan here again! 👋 DEV is a friendly community. " \ - "Why not introduce yourself by leaving a comment in the welcome thread!" - end + processed_html { I18n.t("broadcast.welcome.welcome_thread") } end factory :apple_connect_broadcast do title { "Welcome Notification: apple_connect" } type_of { "Welcome" } - processed_html do - "You're on a roll! 🎉 Do you have an Apple account? Consider connecting it." - end + processed_html { I18n.t("broadcast.connect.apple") } end factory :github_connect_broadcast do title { "Welcome Notification: github_connect" } type_of { "Welcome" } - processed_html do - "You're on a roll! 🎉 Do you have a GitHub account? Consider " \ - "connecting it so you can pin any of your repos to your profile." - end + processed_html { I18n.t("broadcast.connect.github") } end factory :google_oauth2_connect_broadcast do title { "Welcome Notification: google_oauth2_connect" } type_of { "Welcome" } - processed_html do - "You're on a roll! 🎉 Do you have a Google account? Consider " \ - "connecting it." - end + processed_html { I18n.t("broadcast.connect.google") } end factory :facebook_connect_broadcast do title { "Welcome Notification: facebook_connect" } type_of { "Welcome" } - processed_html do - "You're on a roll! 🎉 Do you have a Facebook account? Consider " \ - "connecting it." - end + processed_html { I18n.t("broadcast.connect.facebook") } end factory :forem_connect_broadcast do title { "Welcome Notification: forem_connect" } type_of { "Welcome" } - processed_html do - "You're on a roll! 🎉 Do you have a Forem account? Consider " \ - "connecting it." - end + processed_html { I18n.t("broadcast.connect.forem") } end factory :twitter_connect_broadcast do title { "Welcome Notification: twitter_connect" } type_of { "Welcome" } - processed_html do - "You're on a roll! 🎉 Do you have a Twitter account? Consider " \ - "connecting it so we can @mention you if we share " \ - "your post via our Twitter account @thePracticalDev." - end + processed_html { I18n.t("broadcast.connect.twitter") } end factory :customize_ux_broadcast do title { "Welcome Notification: customize_experience" } type_of { "Welcome" } - processed_html do - "Sloan here! 👋 Did you know that that you can customize your DEV experience? " \ - "Try changing your font and theme and find the best style for you!" - end + processed_html { I18n.t("broadcast.welcome.customize_experience") } end factory :customize_feed_broadcast do title { "Welcome Notification: customize_feed" } type_of { "Welcome" } - processed_html do - "Hi, it's me again! 👋 Now that you're a part of the DEV community, " \ - "let's focus on personalizing your content. You can start by " \ - "following some tags to help customize your feed! 🎉" - end + processed_html { I18n.t("broadcast.welcome.customize_feed") } end factory :start_discussion_broadcast do title { "Welcome Notification: start_discussion" } type_of { "Welcome" } - processed_html do - "Sloan here! 👋 I noticed that you haven't " \ - "started a discussion yet. " \ - "Starting a discussion is easy to do; just click on 'Create Post' " \ - "in the sidebar of the tag page to get started!" - end + processed_html { I18n.t("broadcast.welcome.start_discussion") } end factory :ask_question_broadcast do title { "Welcome Notification: ask_question" } type_of { "Welcome" } - processed_html do - "Sloan here! 👋 I noticed that you haven't " \ - "asked a question yet. " \ - "Asking a question is easy to do; just click on 'Create Post' in the sidebar of the tag page to get started!" - end + processed_html { I18n.t("broadcast.welcome.ask_question") } end factory :discuss_and_ask_broadcast do title { "Welcome Notification: discuss_and_ask" } type_of { "Welcome" } - processed_html do - "Sloan here! 👋 I noticed that you haven't " \ - "asked a question or " \ - "started a discussion yet. " \ - "It's easy to do both of these; just click on 'Create Post' in the sidebar of the tag page to get started!" - end + processed_html { I18n.t("broadcast.welcome.discuss_and_ask") } end factory :download_app_broadcast do title { "Welcome Notification: download_app" } type_of { "Welcome" } - processed_html do - "Sloan here, with one last tip! 👋 Have you downloaded the DEV mobile " \ - "app yet? Consider downloading it " \ - "so you can access all of your favorite DEV content on the go!" - end + processed_html { I18n.t("broadcast.welcome.download_app") } end factory :announcement_broadcast do