Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: moves translations under discourse_post_event #627

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions app/controllers/discourse_post_event/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 6 additions & 16 deletions app/models/discourse_post_event/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<DButton
@label="discourse_calendar.discourse_post_event.bulk_invite_modal.download_sample_csv"
@label="discourse_post_event.bulk_invite_modal.download_sample_csv"
@action={{action "downloadSampleCsv"}}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export default class DiscoursePostEventCreator extends Component {

<template>
<span class="creators">
<span class="created-by">{{i18n
"discourse_calendar.discourse_post_event.event_ui.created_by"
}}</span>
<span class="created-by">{{i18n "discourse_post_event.created_by"}}</span>

<span class="event-creator">
<a class="topic-invitee-avatar" data-user-card={{@user.username}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import i18n from "discourse-common/helpers/i18n";
export default class EventStatus extends Component {
get eventStatusLabel() {
return i18n(
`discourse_calendar.discourse_post_event.models.event.status.${this.args.event.status}.title`
`discourse_post_event.models.event.status.${this.args.event.status}.title`
);
}

get eventStatusDescription() {
return i18n(
`discourse_calendar.discourse_post_event.models.event.status.${this.args.event.status}.description`
`discourse_post_event.models.event.status.${this.args.event.status}.description`
);
}

Expand All @@ -21,11 +21,11 @@ export default class EventStatus extends Component {
<template>
{{#if @event.isExpired}}
<span class="status expired">
{{i18n "discourse_calendar.discourse_post_event.models.event.expired"}}
{{i18n "discourse_post_event.models.event.expired"}}
</span>
{{else if @event.isClosed}}
<span class="status closed">
{{i18n "discourse_calendar.discourse_post_event.models.event.closed"}}
{{i18n "discourse_post_event.models.event.closed"}}
</span>
{{else}}
<span class={{this.statusClass}} title={{this.eventStatusDescription}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class DiscoursePostEventInvitee extends Component {
}

get flairName() {
const string = `discourse_calendar.discourse_post_event.models.invitee.status.${this.args.invitee.status}`;
const string = `discourse_post_event.models.invitee.status.${this.args.invitee.status}`;

return i18n(string);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class DiscoursePostEventInvitees extends Component {
const count = this.args.event.stats[button] || 0;

const label = i18n(
`discourse_calendar.discourse_post_event.models.invitee.status.${localeKey}_count`,
`discourse_post_event.models.invitee.status.${localeKey}_count`,
{ count }
);

Expand All @@ -66,7 +66,7 @@ export default class DiscoursePostEventInvitees extends Component {

<DButton
class="show-all btn-small"
@label="discourse_calendar.discourse_post_event.event_ui.show_all"
@label="discourse_post_event.show_all"
@action={{this.showAllInvitees}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
this.menuApi.close();

this.dialog.yesNoConfirm({
message: i18n(
"discourse_calendar.discourse_post_event.builder_modal.confirm_open"
),
message: i18n("discourse_post_event.builder_modal.confirm_open"),
didConfirm: async () => {
try {
const post = await this.store.find("post", this.args.event.id);
Expand All @@ -147,9 +145,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
if (newRaw) {
const props = {
raw: newRaw,
edit_reason: i18n(
"discourse_calendar.discourse_post_event.edit_reason_opened"
),
edit_reason: i18n("discourse_post_event.edit_reason_opened"),
};

const cooked = await cook(newRaw);
Expand Down Expand Up @@ -192,9 +188,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
this.menuApi.close();

this.dialog.yesNoConfirm({
message: i18n(
"discourse_calendar.discourse_post_event.builder_modal.confirm_close"
),
message: i18n("discourse_post_event.builder_modal.confirm_close"),
didConfirm: () => {
return this.store.find("post", this.args.event.id).then((post) => {
this.args.event.isClosed = true;
Expand All @@ -211,9 +205,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
if (newRaw) {
const props = {
raw: newRaw,
edit_reason: i18n(
"discourse_calendar.discourse_post_event.edit_reason_closed"
),
edit_reason: i18n("discourse_post_event.edit_reason_closed"),
};

return cook(newRaw).then((cooked) => {
Expand All @@ -239,7 +231,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<dropdown.item class="add-to-calendar">
<DButton
@icon="file"
@label="discourse_calendar.discourse_post_event.event_ui.add_to_calendar"
@label="discourse_post_event.add_to_calendar"
@action={{this.addToCalendar}}
/>
</dropdown.item>
Expand All @@ -251,7 +243,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
@icon="envelope"
class="btn-transparent"
@translatedLabel={{i18n
"discourse_calendar.discourse_post_event.event_ui.send_pm_to_creator"
"discourse_post_event.send_pm_to_creator"
(hash [email protected])
}}
@action={{this.sendPMToCreator}}
Expand All @@ -264,9 +256,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<DButton
@icon="user-plus"
class="btn-transparent"
@translatedLabel={{i18n
"discourse_calendar.discourse_post_event.event_ui.invite"
}}
@translatedLabel={{i18n "discourse_post_event.invite"}}
@action={{this.inviteUserOrGroup}}
/>
</dropdown.item>
Expand All @@ -277,9 +267,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<DButton
@icon="far-calendar-plus"
class="btn-transparent"
@translatedLabel={{i18n
"discourse_post_event.event_ui.upcoming_events"
}}
@translatedLabel={{i18n "discourse_post_event.upcoming_events"}}
@action={{this.upcomingEvents}}
/>
</dropdown.item>
Expand All @@ -290,7 +278,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<DButton
@icon="user-group"
class="btn-transparent"
@label="discourse_calendar.discourse_post_event.event_ui.show_participants"
@label="discourse_post_event.show_participants"
@action={{this.showParticipants}}
/>
</dropdown.item>
Expand All @@ -301,7 +289,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<DButton
@icon="file-csv"
class="btn-transparent"
@label="discourse_calendar.discourse_post_event.event_ui.export_event"
@label="discourse_post_event.export_event"
@action={{this.exportPostEvent}}
/>
</dropdown.item>
Expand All @@ -311,7 +299,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<DButton
@icon="file-upload"
class="btn-transparent"
@label="discourse_calendar.discourse_post_event.event_ui.bulk_invite"
@label="discourse_post_event.bulk_invite"
@action={{this.bulkInvite}}
/>
</dropdown.item>
Expand All @@ -322,7 +310,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<DButton
@icon="unlock"
class="btn-transparent"
@label="discourse_calendar.discourse_post_event.event_ui.open_event"
@label="discourse_post_event.open_event"
@action={{this.openEvent}}
/>
</dropdown.item>
Expand All @@ -331,7 +319,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<DButton
@icon="pencil-alt"
class="btn-transparent"
@label="discourse_calendar.discourse_post_event.event_ui.edit_event"
@label="discourse_post_event.edit_event"
@action={{this.editPostEvent}}
/>
</dropdown.item>
Expand All @@ -340,7 +328,7 @@ export default class DiscoursePostEventMoreMenu extends Component {
<dropdown.item class="close-event">
<DButton
@icon="times"
@label="discourse_calendar.discourse_post_event.event_ui.close_event"
@label="discourse_post_event.close_event"
@action={{this.closeEvent}}
class="btn-transparent btn-danger"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class DiscoursePostEventStatus extends Component {
<DButton
class="going-button"
@icon="check"
@label="discourse_calendar.discourse_post_event.models.invitee.status.going"
@label="discourse_post_event.models.invitee.status.going"
@action={{fn this.changeWatchingInviteeStatus "going"}}
/>
</PluginOutlet>
Expand All @@ -152,7 +152,7 @@ export default class DiscoursePostEventStatus extends Component {
<DButton
class="interested-button"
@icon="star"
@label="discourse_calendar.discourse_post_event.models.invitee.status.interested"
@label="discourse_post_event.models.invitee.status.interested"
@action={{fn this.changeWatchingInviteeStatus "interested"}}
/>
</PluginOutlet>
Expand All @@ -170,7 +170,7 @@ export default class DiscoursePostEventStatus extends Component {
<DButton
class="not-going-button"
@icon="times"
@label="discourse_calendar.discourse_post_event.models.invitee.status.not_going"
@label="discourse_post_event.models.invitee.status.not_going"
@action={{fn this.changeWatchingInviteeStatus "not_going"}}
/>
</PluginOutlet>
Expand Down
9 changes: 3 additions & 6 deletions assets/javascripts/discourse/components/event-date.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,9 @@ export default class EventDate extends Component {
}

get timeRemainingContent() {
return I18n.t(
"discourse_calendar.discourse_post_event.topic_title.ends_in_duration",
{
duration: this.eventEndedAt.from(moment()),
}
);
return I18n.t("discourse_post_event.topic_title.ends_in_duration", {
duration: this.eventEndedAt.from(moment()),
});
}

_parsedDate(date) {
Expand Down
Loading