feat: expose {time} to eventPost data, fix renamed tooltip (#3698)

This commit is contained in:
IanM 2023-01-17 19:47:02 +00:00 committed by GitHub
parent 4d292263b5
commit 03d2d7eabb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 12 deletions

View File

@ -29,8 +29,8 @@ flarum-lock:
# These translations are displayed between posts in the post stream.
post_stream:
discussion_locked_text: "{username} locked the discussion."
discussion_unlocked_text: "{username} unlocked the discussion."
discussion_locked_text: "{username} locked the discussion {time}."
discussion_unlocked_text: "{username} unlocked the discussion {time}."
# These translations are used in the Settings page.
settings:

View File

@ -25,8 +25,8 @@ flarum-sticky:
# These translations are displayed between posts in the post stream.
post_stream:
discussion_stickied_text: "{username} stickied the discussion."
discussion_unstickied_text: "{username} unstickied the discussion."
discussion_stickied_text: "{username} stickied the discussion {time}."
discussion_unstickied_text: "{username} unstickied the discussion {time}."
##
# REUSED TRANSLATIONS - These keys should not be used directly in code!

View File

@ -92,9 +92,9 @@ flarum-tags:
# These translations are displayed between posts in the post stream.
post_stream:
added_and_removed_tags_text: "{username} added the {tagsAdded} and removed the {tagsRemoved}."
added_tags_text: "{username} added the {tagsAdded}."
removed_tags_text: "{username} removed the {tagsRemoved}."
added_and_removed_tags_text: "{username} added the {tagsAdded} and removed the {tagsRemoved} {time}."
added_tags_text: "{username} added the {tagsAdded} {time}."
removed_tags_text: "{username} removed the {tagsRemoved} {time}."
tags_text: "{count, plural, one {{tags} tag} other {{tags} tags}}"
# These translations are used when visiting a single tag's discussion list.

View File

@ -1,6 +1,7 @@
import app from '../../forum/app';
import EventPost from './EventPost';
import extractText from '../../common/utils/extractText';
import Tooltip from '../../common/components/Tooltip';
/**
* The `DiscussionRenamedPost` component displays a discussion event post
@ -17,9 +18,8 @@ export default class DiscussionRenamedPost extends EventPost {
description(data) {
const renamed = app.translator.trans('core.forum.post_stream.discussion_renamed_text', data);
const oldName = app.translator.trans('core.forum.post_stream.discussion_renamed_old_tooltip', data);
return <span title={extractText(oldName)}>{renamed}</span>;
return <span>{renamed}</span>;
}
descriptionData() {
@ -28,8 +28,11 @@ export default class DiscussionRenamedPost extends EventPost {
const newTitle = post.content()[1];
return {
old: oldTitle,
new: <strong className="DiscussionRenamedPost-new">{newTitle}</strong>,
new: (
<Tooltip text={extractText(app.translator.trans('core.forum.post_stream.discussion_renamed_old_tooltip', { old: oldTitle }))}>
<strong className="DiscussionRenamedPost-new">{newTitle}</strong>
</Tooltip>
),
};
}
}

View File

@ -4,6 +4,7 @@ import { ucfirst } from '../../common/utils/string';
import usernameHelper from '../../common/helpers/username';
import icon from '../../common/helpers/icon';
import Link from '../../common/components/Link';
import humanTime from '../../common/helpers/humanTime';
/**
* The `EventPost` component displays a post which indicating a discussion
@ -37,6 +38,7 @@ export default class EventPost extends Post {
) : (
username
),
time: humanTime(this.attrs.post.createdAt()),
});
return super.content().concat([icon(this.icon(), { className: 'EventPost-icon' }), <div class="EventPost-info">{this.description(data)}</div>]);

View File

@ -446,7 +446,7 @@ core:
# These translations are displayed between posts in the post stream.
post_stream:
discussion_renamed_old_tooltip: 'The old title was: "{old}"'
discussion_renamed_text: "{username} changed the title to {new}."
discussion_renamed_text: "{username} changed the title to {new} {time}."
load_more_button: => core.ref.load_more
reply_placeholder: => core.ref.write_a_reply
time_lapsed_text: "{period} later"