Update badge awarding language (#20516)

* update badge language files

* update admin controller

* fix tests

* no actually fix the tests

* remove 'community' from notification

* fix spec

* fix interpolations
This commit is contained in:
Philip How 2024-01-17 14:26:19 +00:00 committed by GitHub
parent 16ff57c2ff
commit fb855c97bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 35 additions and 21 deletions

View file

@ -22,7 +22,7 @@ module Admin
end
def award
@all_badges = Badge.all.select(:title, :slug).order(title: :asc)
@all_badges = Badge.select(:title, :slug).order(title: :asc)
end
def award_badges
@ -32,7 +32,8 @@ module Admin
end
usernames = permitted_params[:usernames].downcase.split(/\s*,\s*/)
message = permitted_params[:message_markdown].presence || I18n.t("admin.badge_achievements_controller.congrats")
message = permitted_params[:message_markdown].presence ||
I18n.t("admin.badge_achievements_controller.congrats", community: ::Settings::Community.community_name)
BadgeAchievements::BadgeAwardWorker.perform_async(usernames, permitted_params[:badge], message)
flash[:success] = I18n.t("admin.badge_achievements_controller.rewarded")

View file

@ -2,12 +2,16 @@ module Badges
class AwardFabFive
BADGE_SLUG = "fab-5".freeze
def self.call(usernames, message_markdown = I18n.t("services.badges.congrats"))
def self.call(usernames, message_markdown = default_message_markdown)
::Badges::Award.call(
User.where(username: usernames),
BADGE_SLUG,
message_markdown,
)
end
def self.default_message_markdown
I18n.t("services.badges.congrats", community: Settings::Community.community_name)
end
end
end

View file

@ -2,12 +2,16 @@ module Badges
class AwardTopSeven
BADGE_SLUG = "top-7".freeze
def self.call(usernames, message_markdown = I18n.t("services.badges.congrats"))
def self.call(usernames, message_markdown = default_message_markdown)
::Badges::Award.call(
User.where(username: usernames),
BADGE_SLUG,
message_markdown,
)
end
def self.default_message_markdown
I18n.t("services.badges.congrats", community: Settings::Community.community_name)
end
end
end

View file

@ -8,7 +8,7 @@ en:
badge_achievements_controller:
deleted: Badge achievement has been deleted!
rewarded: Badges are being rewarded. The task will finish shortly.
congrats: Congrats!
congrats: Congrats on your achievement! 🎉 And thank you for being such a vital part of %{community}!
award: Please choose a badge to award
wrong: Something went wrong.
badges_controller:

View file

@ -8,7 +8,7 @@ fr:
badge_achievements_controller:
deleted: La réalisation du badge a été supprimée !
rewarded: Les badges sont en train d'être récompensés. La tâche sera bientôt terminée.
congrats: Félicitations !
congrats: Félicitations pour votre succès! 🎉 Et merci d'être une partie si essentielle de %{community} !
award: Veuillez choisir un badge à décerner
wrong: Quelque chose a mal fonctionné.
badges_controller:

View file

@ -17,7 +17,7 @@ en:
award_beloved_comment:
message: "You're famous! [This is the comment](%{comment}) for which you're being recognized. 😄"
award_streak:
longest: 16 weeks! You've achieved the longest writing streak possible. This makes you eligible for special quests in the future. Keep up the amazing contributions to our community!
longest: 16 weeks! You've achieved the longest writing streak possible. Keep up the amazing contributions to our community!
message:
one: "Congrats on achieving this streak! Consistent writing is hard. The next streak badge you can get is the %{count} Week Badge. 😉"
other: "Congrats on achieving this streak! Consistent writing is hard. The next streak badge you can get is the %{count} Week Badge. 😉"
@ -25,13 +25,13 @@ en:
message:
one: Happy %{community} birthday! Can you believe it's been %{count} year already?!
other: Happy %{community} birthday! Can you believe it's been %{count} years already?!
congrats: Congrats!!!
congrats: Congrats on your achievement! 🎉 And thank you for being such a vital part of %{community}!
thank_you: Thank you so much for your contributions!
community_wellness:
first: Thank you for participating in constructive conversation! You posted two or more comments this week. Keep it up to continue the streak!
longest: 32 weeks! You've achieved the longest streak possible for the Community Wellness badge. Amazing job engaging in the community and keep up your amazing contributions to our community!
longest: 32 weeks! You've achieved the longest streak possible for the Community Wellness badge. Amazing job engaging in the community. Keep up your amazing contributions to our community!
other: Congrats on achieving a %{weeks} week streak for the Community Wellness Badge! Keep the constructive comments flowing to continue the streak!
thumbs_up: Thank you for your efforts reviewing posts on and reaching %{count} thumbs-up reactions!
thumbs_up: Thank you for your efforts reviewing posts and reaching %{count} thumbs-up reactions!
broadcasts:
welcome_notification:
generator:

View file

@ -17,21 +17,21 @@ fr:
award_beloved_comment:
message: "Vous êtes célèbre ! [C'est le commentaire](%{comment}) pour lequel vous êtes reconnu. 😄"
award_streak:
longest: 16 semaines ! Vous avez atteint la plus longue série d'écriture possible. Cela vous rend éligible pour des quêtes spéciales à l'avenir. Continuez à apporter votre contribution à notre communauté !
longest: 16 semaines ! Vous avez réalisé la plus longue séquence décriture possible. Continuez vos incroyables contributions à notre communauté!
message:
one: "Félicitations pour avoir atteint cet objectif ! Il est difficile d'écrire de façon constante. Le prochain badge que vous pouvez obtenir est le badge %{count} Semaine. 😉"
other: "Félicitations pour avoir atteint cet objectif ! Il est difficile d'écrire de façon constante. Le prochain badge que vous pouvez obtenir est le badge %{count} Semaine. 😉"
one: "Félicitations pour avoir réalisé cette séquence ! Une écriture cohérente est difficile. Le prochain badge de séquence que vous pouvez obtenir est le badge de semaine %{count}. 😉"
other: "Félicitations pour avoir réalisé cette séquence ! Une écriture cohérente est difficile. Le prochain badge de séquence que vous pouvez obtenir est le badge de semaine %{count}. 😉"
award_yearly_club:
message:
one: Joyeux %{community} anniversaire ! Peux-tu croire que ça fait déjà %{count} an ?!
other: Joyeux %{community} anniversaire ! Peux-tu croire que ça fait déjà %{count} ans ?!
congrats: Félicitations !
one: Joyeux anniversaire %{community} ! Pouvez-vous croire que cela fait déjà %{count} année ?!
other: Joyeux anniversaire %{community} ! Pouvez-vous croire que cela fait déjà %{count} années ?!
congrats: Félicitations pour votre succès! 🎉 Et merci d'être une partie si essentielle de %{community} !
thank_you: Merci beaucoup pour vos contributions !
community_wellness:
first: Merci de participer à une conversation constructive ! Vous avez posté deux commentaires ou plus cette semaine. Continuez comme ça pour poursuivre la série !
longest: 32 semaines ! Vous avez atteint la plus longue période possible pour l'insigne du bien-être communautaire. Vous avez fait un travail remarquable en vous engageant dans la communauté et continuez à apporter votre contribution à notre communauté !
other: Félicitations pour avoir atteint une série de %{weeks} semaines pour l'insigne du bien-être communautaire ! Continuez à envoyer des commentaires constructifs pour que la série continue !
thumbs_up: Merci pour vos efforts en examinant les messages et en obtenant %{count} réactions positives!
longest: 32 semaines ! Vous avez réalisé la plus longue séquence possible pour le badge Community Wellness. Un travail incroyable en m'engageant dans la communauté. Continuez vos incroyables contributions à notre communauté !
other: Félicitations, vous avez réalisé %{weeks} semaines consécutives pour le badge de bien-être communautaire ! Continuez à recevoir des commentaires constructifs pour continuer la séquence !
thumbs_up: Merci pour vos efforts en examinant les messages et en obtenant %{count} réactions positives !
broadcasts:
welcome_notification:
generator:

View file

@ -24,6 +24,10 @@ RSpec.describe "/admin/content_manager/badge_achievements" do
let(:user2) { create(:user) }
let(:usernames_string) { "#{user.username}, #{user2.username}" }
let(:usernames_array) { [user.username, user2.username] }
let(:expected_message) do
"Congrats on your achievement! 🎉 And thank you for being " \
"such a vital part of #{Settings::Community.community_name}!"
end
before do
sign_in admin
@ -68,8 +72,9 @@ RSpec.describe "/admin/content_manager/badge_achievements" do
usernames: usernames_string,
message_markdown: ""
}
expect(BadgeAchievements::BadgeAwardWorker).to have_received(:perform_async).with(usernames_array, badge.slug,
"Congrats!")
expect(BadgeAchievements::BadgeAwardWorker).to have_received(:perform_async).with(usernames_array,
badge.slug,
expected_message)
expect(request.flash[:success]).to include("Badges are being rewarded. The task will finish shortly.")
end