From 85ba8b53247a613676dd00449d2aba57826094c5 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 23 Oct 2024 10:58:02 +0900 Subject: [PATCH] DEV: moves translatations under discourse_post_event Various events in the life of this plugin have caused an over complicated key and duplicated keys. This commits attempts to regroup everything related to discourse_post_event under a top level `discourse_post_event` key, removes the `event_ui` level as it's not very clear, technically everything is UI. And finally attempts to remove the duplicates. --- .../discourse_post_event/events_controller.rb | 12 +- app/models/discourse_post_event/event.rb | 22 +- .../bulk-invite-sample-csv-file.hbs | 2 +- .../discourse-post-event/creator.gjs | 4 +- .../discourse-post-event/event-status.gjs | 8 +- .../discourse-post-event/invitee.gjs | 2 +- .../discourse-post-event/invitees.gjs | 4 +- .../discourse-post-event/more-menu.gjs | 40 +-- .../discourse-post-event/status.gjs | 6 +- .../discourse/components/event-date.gjs | 9 +- .../components/modal/post-event-builder.hbs | 58 ++-- .../components/modal/post-event-builder.js | 36 +-- .../modal/post-event-bulk-invite.hbs | 22 +- .../modal/post-event-bulk-invite.js | 20 +- .../modal/post-event-invite-user-or-group.hbs | 6 +- .../modal/post-event-invitees/index.gjs | 12 +- .../discourse/components/toggle-invitees.hbs | 6 +- .../components/upcoming-events-list.gjs | 22 +- .../initializers/add-event-ui-builder.js | 2 +- .../add-upcoming-events-to-sidebar.js | 8 +- .../initializers/discourse-calendar.js | 2 +- .../discourse-post-event-decorator.gjs | 4 +- .../discourse/lib/event-relative-date.js | 9 +- config/locales/client.en.yml | 282 +++++------------- config/locales/server.en.yml | 56 ++-- .../discourse_post_event/send_reminder.rb | 5 +- lib/discourse_post_event/event_validator.rb | 39 +-- spec/integration/post_spec.rb | 18 +- .../send_reminder_spec.rb | 7 +- .../acceptance/notifications-test.js | 18 +- .../acceptance/post-event-builder-test.js | 4 +- .../components/upcoming-events-list-test.gjs | 48 +-- 32 files changed, 262 insertions(+), 531 deletions(-) diff --git a/app/controllers/discourse_post_event/events_controller.rb b/app/controllers/discourse_post_event/events_controller.rb index 6c1f4c51a..84ea4f06a 100644 --- a/app/controllers/discourse_post_event/events_controller.rb +++ b/app/controllers/discourse_post_event/events_controller.rb @@ -71,18 +71,14 @@ def csv_bulk_invite else render json: failed_json.merge( - errors: [ - I18n.t("discourse_calendar.discourse_post_event.errors.bulk_invite.error"), - ], + errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")], ), status: 422 end rescue StandardError render json: failed_json.merge( - errors: [ - I18n.t("discourse_calendar.discourse_post_event.errors.bulk_invite.error"), - ], + errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")], ), status: 422 end @@ -108,9 +104,7 @@ def bulk_invite rescue StandardError render json: failed_json.merge( - errors: [ - I18n.t("discourse_calendar.discourse_post_event.errors.bulk_invite.error"), - ], + errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")], ), status: 422 end diff --git a/app/models/discourse_post_event/event.rb b/app/models/discourse_post_event/event.rb index 26a353c55..058f1bc3f 100644 --- a/app/models/discourse_post_event/event.rb +++ b/app/models/discourse_post_event/event.rb @@ -128,10 +128,7 @@ def raw_invitees_length if self.raw_invitees && self.raw_invitees.length > 10 errors.add( :base, - I18n.t( - "discourse_calendar.discourse_post_event.errors.models.event.raw_invitees_length", - count: 10, - ), + I18n.t("discourse_post_event.errors.models.event.raw_invitees_length", count: 10), ) end end @@ -141,9 +138,7 @@ def raw_invitees_are_groups if self.raw_invitees && User.select(:id).where(username: self.raw_invitees).limit(1).count > 0 errors.add( :base, - I18n.t( - "discourse_calendar.discourse_post_event.errors.models.event.raw_invitees.only_group", - ), + I18n.t("discourse_post_event.errors.models.event.raw_invitees.only_group"), ) end end @@ -154,9 +149,7 @@ def ends_before_start self.original_starts_at >= self.original_ends_at errors.add( :base, - I18n.t( - "discourse_calendar.discourse_post_event.errors.models.event.ends_at_before_starts_at", - ), + I18n.t("discourse_post_event.errors.models.event.ends_at_before_starts_at"), ) end end @@ -168,10 +161,7 @@ def allowed_custom_fields if !allowed_custom_fields.include?(key) errors.add( :base, - I18n.t( - "discourse_calendar.discourse_post_event.errors.models.event.custom_field_is_invalid", - field: key, - ), + I18n.t("discourse_post_event.errors.models.event.custom_field_is_invalid", field: key), ) end end @@ -209,9 +199,9 @@ def create_notification!(user, post, predefined_attendance: false) message = if predefined_attendance - "discourse_calendar.discourse_post_event.notifications.invite_user_predefined_attendance_notification" + "discourse_post_event.notifications.invite_user_predefined_attendance_notification" else - "discourse_calendar.discourse_post_event.notifications.invite_user_notification" + "discourse_post_event.notifications.invite_user_notification" end attrs = { diff --git a/assets/javascripts/discourse/components/bulk-invite-sample-csv-file.hbs b/assets/javascripts/discourse/components/bulk-invite-sample-csv-file.hbs index e7086e1c2..0a3bef804 100644 --- a/assets/javascripts/discourse/components/bulk-invite-sample-csv-file.hbs +++ b/assets/javascripts/discourse/components/bulk-invite-sample-csv-file.hbs @@ -1,4 +1,4 @@ \ No newline at end of file diff --git a/assets/javascripts/discourse/components/discourse-post-event/creator.gjs b/assets/javascripts/discourse/components/discourse-post-event/creator.gjs index f115873d1..d877b9e48 100644 --- a/assets/javascripts/discourse/components/discourse-post-event/creator.gjs +++ b/assets/javascripts/discourse/components/discourse-post-event/creator.gjs @@ -10,9 +10,7 @@ export default class DiscoursePostEventCreator extends Component {