From 0a1191d56c15da506f8798a7c3e00295d7036b04 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Fri, 17 Jul 2015 17:43:28 +0930 Subject: [PATCH] Make front-end localizable --- .../js/forum/src/components/ActivityPage.js | 2 +- .../js/forum/src/components/AvatarEditor.js | 4 +- .../forum/src/components/ChangeEmailModal.js | 12 +- .../src/components/ChangePasswordModal.js | 8 +- .../core/js/forum/src/components/Composer.js | 8 +- .../src/components/DeleteAccountModal.js | 8 +- .../src/components/DiscussionComposer.js | 8 +- .../js/forum/src/components/DiscussionList.js | 2 +- .../src/components/DiscussionListItem.js | 5 +- .../DiscussionRenamedNotification.js | 2 +- .../src/components/DiscussionRenamedPost.js | 6 +- .../src/components/DiscussionsSearchSource.js | 4 +- .../forum/src/components/EditPostComposer.js | 6 +- .../forum/src/components/FooterSecondary.js | 2 +- .../src/components/ForgotPasswordModal.js | 14 ++- .../forum/src/components/HeaderSecondary.js | 4 +- .../core/js/forum/src/components/IndexPage.js | 10 +- .../js/forum/src/components/JoinedActivity.js | 2 +- .../js/forum/src/components/LogInModal.js | 16 +-- .../forum/src/components/NotificationGrid.js | 6 +- .../forum/src/components/NotificationList.js | 6 +- .../src/components/NotificationsDropdown.js | 2 +- .../js/forum/src/components/PostEdited.js | 3 +- .../core/js/forum/src/components/PostMeta.js | 2 +- .../js/forum/src/components/PostStream.js | 2 +- .../src/components/PostStreamScrubber.js | 16 ++- .../js/forum/src/components/PostedActivity.js | 2 +- .../js/forum/src/components/ReplyComposer.js | 10 +- .../forum/src/components/ReplyPlaceholder.js | 2 +- .../core/js/forum/src/components/Search.js | 2 +- .../forum/src/components/SessionDropdown.js | 8 +- .../js/forum/src/components/SettingsPage.js | 16 +-- .../js/forum/src/components/SignUpModal.js | 30 +++-- .../js/forum/src/components/TerminalPost.js | 7 +- .../js/forum/src/components/TextEditor.js | 6 - .../core/js/forum/src/components/UserBio.js | 7 +- .../core/js/forum/src/components/UserCard.js | 4 +- .../core/js/forum/src/components/UserPage.js | 8 +- .../forum/src/components/UsersSearchSource.js | 2 +- .../js/forum/src/utils/DiscussionControls.js | 15 +-- .../core/js/forum/src/utils/PostControls.js | 8 +- .../core/js/forum/src/utils/UserControls.js | 4 +- .../core/js/forum/src/utils/extractText.js | 19 +++ framework/core/js/lib/Translator.js | 34 +++-- framework/core/js/lib/components/Dropdown.js | 2 +- framework/core/js/lib/components/Modal.js | 1 - framework/core/js/lib/models/User.js | 4 +- framework/core/locale/en/translations.yml | 116 ++++++++++++++++- .../core/src/Forum/Actions/ClientAction.php | 119 ++++++++++++++++++ 49 files changed, 438 insertions(+), 148 deletions(-) create mode 100644 framework/core/js/forum/src/utils/extractText.js diff --git a/framework/core/js/forum/src/components/ActivityPage.js b/framework/core/js/forum/src/components/ActivityPage.js index cedc3b535..ce7a61833 100644 --- a/framework/core/js/forum/src/components/ActivityPage.js +++ b/framework/core/js/forum/src/components/ActivityPage.js @@ -49,7 +49,7 @@ export default class ActivityPage extends UserPage { footer = (
{Button.component({ - children: 'Load More', + children: app.trans('core.load_more'), className: 'Button--default', onclick: this.loadMore.bind(this) })} diff --git a/framework/core/js/forum/src/components/AvatarEditor.js b/framework/core/js/forum/src/components/AvatarEditor.js index 40730693d..9569d888d 100644 --- a/framework/core/js/forum/src/components/AvatarEditor.js +++ b/framework/core/js/forum/src/components/AvatarEditor.js @@ -62,7 +62,7 @@ export default class AvatarEditor extends Component { items.add('upload', Button.component({ icon: 'upload', - children: 'Upload', + children: app.trans('core.upload'), onclick: this.upload.bind(this) }) ); @@ -70,7 +70,7 @@ export default class AvatarEditor extends Component { items.add('remove', Button.component({ icon: 'times', - children: 'Remove', + children: app.trans('core.remove'), onclick: this.remove.bind(this) }) ); diff --git a/framework/core/js/forum/src/components/ChangeEmailModal.js b/framework/core/js/forum/src/components/ChangeEmailModal.js index b58235752..8c23890e9 100644 --- a/framework/core/js/forum/src/components/ChangeEmailModal.js +++ b/framework/core/js/forum/src/components/ChangeEmailModal.js @@ -28,7 +28,7 @@ export default class ChangeEmailModal extends Modal { } title() { - return 'Change Email'; + return app.trans('core.change_email'); } content() { @@ -38,9 +38,11 @@ export default class ChangeEmailModal extends Modal { return (
-

We've sent a confirmation email to {this.email()}. If it doesn't arrive soon, check your spam folder.

+

{m.trust(app.trans('core.confirmation_email_sent', {email: this.email()}))}

@@ -58,7 +60,9 @@ export default class ChangeEmailModal extends Modal { disabled={this.loading}/>
- +
diff --git a/framework/core/js/forum/src/components/ChangePasswordModal.js b/framework/core/js/forum/src/components/ChangePasswordModal.js index 946af808e..46f1c4d1f 100644 --- a/framework/core/js/forum/src/components/ChangePasswordModal.js +++ b/framework/core/js/forum/src/components/ChangePasswordModal.js @@ -10,16 +10,18 @@ export default class ChangePasswordModal extends Modal { } title() { - return 'Change Password'; + return app.trans('core.change_password'); } content() { return (
-

Click the button below and check your email for a link to change your password.

+

{app.trans('core.change_password_help')}

- +
diff --git a/framework/core/js/forum/src/components/Composer.js b/framework/core/js/forum/src/components/Composer.js index f971ed749..7dbe170c3 100644 --- a/framework/core/js/forum/src/components/Composer.js +++ b/framework/core/js/forum/src/components/Composer.js @@ -434,28 +434,28 @@ class Composer extends Component { if (this.position === Composer.PositionEnum.FULLSCREEN) { items.add('exitFullScreen', ComposerButton.component({ icon: 'compress', - title: 'Exit Full Screen', + title: app.trans('core.exit_full_screen'), onclick: this.exitFullScreen.bind(this) })); } else { if (this.position !== Composer.PositionEnum.MINIMIZED) { items.add('minimize', ComposerButton.component({ icon: 'minus minimize', - title: 'Minimize', + title: app.trans('core.minimize'), onclick: this.minimize.bind(this), itemClassName: 'App-backControl' })); items.add('fullScreen', ComposerButton.component({ icon: 'expand', - title: 'Full Screen', + title: app.trans('core.full_screen'), onclick: this.fullScreen.bind(this) })); } items.add('close', ComposerButton.component({ icon: 'times', - title: 'Close', + title: app.trans('core.close'), onclick: this.close.bind(this) })); } diff --git a/framework/core/js/forum/src/components/DeleteAccountModal.js b/framework/core/js/forum/src/components/DeleteAccountModal.js index 463101a7a..0be9ff5d9 100644 --- a/framework/core/js/forum/src/components/DeleteAccountModal.js +++ b/framework/core/js/forum/src/components/DeleteAccountModal.js @@ -23,7 +23,7 @@ export default class DeleteAccountModal extends Modal { } title() { - return 'Delete Account'; + return app.trans('core.delete_account'); } content() { @@ -31,10 +31,10 @@ export default class DeleteAccountModal extends Modal {
-

Hold up! If you delete your account, there's no going back. Keep in mind:

+

{app.trans('core.delete_account_help')}

    -
  • Your username will be released, so someone else will be able to sign up with your name.
  • -
  • All of your posts will remain, but no longer associated with your account.
  • +
  • {app.trans('core.username_will_be_released')}
  • +
  • {app.trans('core.posts_will_remain')}
diff --git a/framework/core/js/forum/src/components/DiscussionComposer.js b/framework/core/js/forum/src/components/DiscussionComposer.js index df2c2f3f0..54bcd5810 100644 --- a/framework/core/js/forum/src/components/DiscussionComposer.js +++ b/framework/core/js/forum/src/components/DiscussionComposer.js @@ -26,10 +26,10 @@ export default class DiscussionComposer extends ComposerBody { static initProps(props) { super.initProps(props); - props.placeholder = props.placeholder || 'Write a Post...'; - props.submitLabel = props.submitLabel || 'Post Discussion'; - props.confirmExit = props.confirmExit || 'You have not posted your discussion. Do you wish to discard it?'; - props.titlePlaceholder = props.titlePlaceholder || 'Discussion Title'; + props.placeholder = props.placeholder || app.trans('core.write_a_post'); + props.submitLabel = props.submitLabel || app.trans('core.post_discussion'); + props.confirmExit = props.confirmExit || app.trans('core.confirm_discard_discussion'); + props.titlePlaceholder = props.titlePlaceholder || app.trans('core.discussion_title'); } headerItems() { diff --git a/framework/core/js/forum/src/components/DiscussionList.js b/framework/core/js/forum/src/components/DiscussionList.js index 8b1e0e82f..faf94a923 100644 --- a/framework/core/js/forum/src/components/DiscussionList.js +++ b/framework/core/js/forum/src/components/DiscussionList.js @@ -53,7 +53,7 @@ export default class DiscussionList extends Component { loading = LoadingIndicator.component(); } else if (this.moreResults) { loading = Button.component({ - children: 'Load More', + children: app.trans('core.load_more'), className: 'Button', onclick: this.loadMore.bind(this) }); diff --git a/framework/core/js/forum/src/components/DiscussionListItem.js b/framework/core/js/forum/src/components/DiscussionListItem.js index 1155ee726..f772cfbdd 100644 --- a/framework/core/js/forum/src/components/DiscussionListItem.js +++ b/framework/core/js/forum/src/components/DiscussionListItem.js @@ -12,6 +12,7 @@ import PostPreview from 'flarum/components/PostPreview'; import SubtreeRetainer from 'flarum/utils/SubtreeRetainer'; import DiscussionControls from 'flarum/utils/DiscussionControls'; import slidable from 'flarum/utils/slidable'; +import extractText from 'flarum/utils/extractText'; /** * The `DiscussionListItem` component shows a single discussion in the @@ -66,7 +67,7 @@ export default class DiscussionListItem extends Component {
+ title={showUnread ? app.trans('core.mark_as_read') : ''}> {abbreviateNumber(discussion[showUnread ? 'unreadCount' : 'repliesCount']())} diff --git a/framework/core/js/forum/src/components/DiscussionRenamedNotification.js b/framework/core/js/forum/src/components/DiscussionRenamedNotification.js index 61713a697..69affe8ac 100644 --- a/framework/core/js/forum/src/components/DiscussionRenamedNotification.js +++ b/framework/core/js/forum/src/components/DiscussionRenamedNotification.js @@ -21,6 +21,6 @@ export default class DiscussionRenamedNotification extends Notification { } content() { - return [username(this.props.notification.sender()), ' changed the title']; + return app.trans('core.discussion_renamed_notification', {user: this.props.notification.sender()}); } } diff --git a/framework/core/js/forum/src/components/DiscussionRenamedPost.js b/framework/core/js/forum/src/components/DiscussionRenamedPost.js index 21c39241e..0827e43fe 100644 --- a/framework/core/js/forum/src/components/DiscussionRenamedPost.js +++ b/framework/core/js/forum/src/components/DiscussionRenamedPost.js @@ -18,6 +18,10 @@ export default class DiscussionRenamedPost extends EventPost { const oldTitle = post.content()[0]; const newTitle = post.content()[1]; - return ['changed the title from ', m('strong.DiscussionRenamedPost-old', oldTitle), ' to ', m('strong.DiscussionRenamedPost-new', newTitle), '.']; + return app.trans('core.discussion_renamed', { + user: this.props.post.user(), + old: {oldTitle}, + new: {newTitle} + }); } } diff --git a/framework/core/js/forum/src/components/DiscussionsSearchSource.js b/framework/core/js/forum/src/components/DiscussionsSearchSource.js index 6cef59a62..c50e50339 100644 --- a/framework/core/js/forum/src/components/DiscussionsSearchSource.js +++ b/framework/core/js/forum/src/components/DiscussionsSearchSource.js @@ -28,11 +28,11 @@ export default class DiscussionsSearchSource { const results = this.results[query] || []; return [ -
  • Discussions
  • , +
  • {app.trans('core.discussions')}
  • ,
  • {LinkButton.component({ icon: 'search', - children: 'Search all discussions for "' + query + '"', + children: app.trans('core.search_all_discussions', {query}), href: app.route('index', {q: query}) })}
  • , diff --git a/framework/core/js/forum/src/components/EditPostComposer.js b/framework/core/js/forum/src/components/EditPostComposer.js index 2dbabc4b4..25d4d60cd 100644 --- a/framework/core/js/forum/src/components/EditPostComposer.js +++ b/framework/core/js/forum/src/components/EditPostComposer.js @@ -15,8 +15,8 @@ export default class EditPostComposer extends ComposerBody { static initProps(props) { super.initProps(props); - props.submitLabel = props.submitLabel || 'Save Changes'; - props.confirmExit = props.confirmExit || 'You have not saved your changes. Do you wish to discard them?'; + props.submitLabel = props.submitLabel || app.trans('core.save_changes'); + props.confirmExit = props.confirmExit || app.trans('core.confirm_discard_edit'); props.originalContent = props.originalContent || props.post.content(); props.user = props.user || props.post.user(); } @@ -29,7 +29,7 @@ export default class EditPostComposer extends ComposerBody {

    {icon('pencil')}{' '} - Post #{post.number()} in {post.discussion().title()} + {app.trans('core.editing_post', {number: post.number(), discussion: post.discussion().title()})}

    )); diff --git a/framework/core/js/forum/src/components/FooterSecondary.js b/framework/core/js/forum/src/components/FooterSecondary.js index 0131e5636..1936b5d57 100644 --- a/framework/core/js/forum/src/components/FooterSecondary.js +++ b/framework/core/js/forum/src/components/FooterSecondary.js @@ -26,7 +26,7 @@ export default class FooterSecondary extends Component { items.add('poweredBy', ( - Powered by Flarum + {app.trans('core.powered_by_flarum')} )); diff --git a/framework/core/js/forum/src/components/ForgotPasswordModal.js b/framework/core/js/forum/src/components/ForgotPasswordModal.js index 1c687e30c..3dd15ae0c 100644 --- a/framework/core/js/forum/src/components/ForgotPasswordModal.js +++ b/framework/core/js/forum/src/components/ForgotPasswordModal.js @@ -33,7 +33,7 @@ export default class ForgotPasswordModal extends Modal { } title() { - return 'Forgot Password'; + return app.trans('core.forgot_password'); } content() { @@ -43,9 +43,11 @@ export default class ForgotPasswordModal extends Modal { return (
    -

    We've sent you an email containing a link to reset your password. Check your spam folder if you don't receive it within the next minute or two.

    +

    {app.trans('core.password_reset_email_sent')}

    @@ -55,16 +57,16 @@ export default class ForgotPasswordModal extends Modal { return (
    -

    Enter your email address and we will send you a link to reset your password.

    +

    {app.trans('core.forgot_password_help')}

    -
    diff --git a/framework/core/js/forum/src/components/HeaderSecondary.js b/framework/core/js/forum/src/components/HeaderSecondary.js index 6f835117e..a2cd4d5d8 100644 --- a/framework/core/js/forum/src/components/HeaderSecondary.js +++ b/framework/core/js/forum/src/components/HeaderSecondary.js @@ -37,7 +37,7 @@ export default class HeaderSecondary extends Component { } else { items.add('signUp', Button.component({ - children: 'Sign Up', + children: app.trans('core.sign_up'), className: 'Button Button--link', onclick: () => app.modal.show(new SignUpModal()) }) @@ -45,7 +45,7 @@ export default class HeaderSecondary extends Component { items.add('logIn', Button.component({ - children: 'Log In', + children: app.trans('core.log_in'), className: 'Button Button--link', onclick: () => app.modal.show(new LogInModal()) }) diff --git a/framework/core/js/forum/src/components/IndexPage.js b/framework/core/js/forum/src/components/IndexPage.js index f79d6981d..0b203518a 100644 --- a/framework/core/js/forum/src/components/IndexPage.js +++ b/framework/core/js/forum/src/components/IndexPage.js @@ -139,7 +139,7 @@ export default class IndexPage extends Component { items.add('newDiscussion', Button.component({ - children: 'Start a Discussion', + children: app.trans('core.start_a_discussion'), icon: 'edit', className: 'Button Button--primary IndexPage-newDiscussion', itemClassName: 'App-primaryControl', @@ -171,7 +171,7 @@ export default class IndexPage extends Component { items.add('allDiscussions', LinkButton.component({ href: app.route('index', params), - children: 'All Discussions', + children: app.trans('core.all_discussions'), icon: 'comments-o' }) ); @@ -191,7 +191,7 @@ export default class IndexPage extends Component { const sortOptions = {}; for (const i in app.cache.discussionList.sortMap()) { - sortOptions[i] = i.substr(0, 1).toUpperCase() + i.substr(1); + sortOptions[i] = app.trans('core.sort_' + i); } items.add('sort', @@ -216,7 +216,7 @@ export default class IndexPage extends Component { items.add('refresh', Button.component({ - title: 'Refresh', + title: app.trans('core.refresh'), icon: 'refresh', className: 'Button Button--icon', onclick: () => app.cache.discussionList.refresh() @@ -226,7 +226,7 @@ export default class IndexPage extends Component { if (app.session.user) { items.add('markAllAsRead', Button.component({ - title: 'Mark All as Read', + title: app.trans('core.mark_all_as_read'), icon: 'check', className: 'Button Button--icon', onclick: this.markAllAsRead.bind(this) diff --git a/framework/core/js/forum/src/components/JoinedActivity.js b/framework/core/js/forum/src/components/JoinedActivity.js index 08e4121d5..1b4df8917 100644 --- a/framework/core/js/forum/src/components/JoinedActivity.js +++ b/framework/core/js/forum/src/components/JoinedActivity.js @@ -6,6 +6,6 @@ import Activity from 'flarum/components/Activity'; */ export default class JoinedActivity extends Activity { description() { - return 'Joined the forum'; + return app.trans('core.joined_the_forum'); } } diff --git a/framework/core/js/forum/src/components/LogInModal.js b/framework/core/js/forum/src/components/LogInModal.js index f26124281..eb2005932 100644 --- a/framework/core/js/forum/src/components/LogInModal.js +++ b/framework/core/js/forum/src/components/LogInModal.js @@ -35,7 +35,7 @@ export default class LogInModal extends Modal { } title() { - return 'Log In'; + return app.trans('core.log_in'); } content() { @@ -43,14 +43,14 @@ export default class LogInModal extends Modal {
    -
    - @@ -67,11 +67,11 @@ export default class LogInModal extends Modal {
    ,

    - Forgot password? + {app.trans('core.forgot_password_link')}

    - Don't have an account?{' '} - Sign Up + {app.trans('core.before_sign_up_link')}{' '} + {app.trans('core.sign_up')}

    ]; @@ -122,12 +122,12 @@ export default class LogInModal extends Modal { if (response && response.code === 'confirm_email') { this.alert = Alert.component({ - children: ['You need to confirm your email before you can log in. We\'ve sent a confirmation email to ', {response.email}, '. If it doesn\'t arrive soon, check your spam folder.'] + children: app.trans('core.email_confirmation_required', {email: response.email}) }); } else { this.alert = Alert.component({ type: 'error', - children: 'Your login details were incorrect.' + children: app.trans('core.invalid_login') }); } diff --git a/framework/core/js/forum/src/components/NotificationGrid.js b/framework/core/js/forum/src/components/NotificationGrid.js index 7800b17c7..d1492e921 100644 --- a/framework/core/js/forum/src/components/NotificationGrid.js +++ b/framework/core/js/forum/src/components/NotificationGrid.js @@ -21,8 +21,8 @@ export default class NotificationGrid extends Component { * @type {Array} */ this.methods = [ - {name: 'alert', icon: 'bell', label: 'Alert'}, - {name: 'email', icon: 'envelope-o', label: 'Email'} + {name: 'alert', icon: 'bell', label: app.trans('core.alert')}, + {name: 'email', icon: 'envelope-o', label: app.trans('core.email')} ]; /** @@ -181,7 +181,7 @@ export default class NotificationGrid extends Component { items.add('discussionRenamed', { name: 'discussionRenamed', - label: [icon('pencil'), ' Someone renames a discussion I started'] + label: [icon('pencil'), ' ', app.trans('core.notify_discussion_renamed')] }); return items; diff --git a/framework/core/js/forum/src/components/NotificationList.js b/framework/core/js/forum/src/components/NotificationList.js index 776fdc2b8..49b33c9fd 100644 --- a/framework/core/js/forum/src/components/NotificationList.js +++ b/framework/core/js/forum/src/components/NotificationList.js @@ -59,12 +59,12 @@ export default class NotificationList extends Component { {Button.component({ className: 'Button Button--icon Button--link', icon: 'check', - title: 'Mark All as Read', + title: app.trans('core.mark_all_as_read'), onclick: this.markAllAsRead.bind(this) })}
    -

    Notifications

    +

    {app.trans('core.notifications')}

    @@ -98,7 +98,7 @@ export default class NotificationList extends Component { ); }) : !this.loading - ?
    No Notifications
    + ?
    {app.trans('core.no_notifications')}
    : LoadingIndicator.component({className: 'LoadingIndicator--block'})}
    diff --git a/framework/core/js/forum/src/components/NotificationsDropdown.js b/framework/core/js/forum/src/components/NotificationsDropdown.js index aebffc16c..b75fa4289 100644 --- a/framework/core/js/forum/src/components/NotificationsDropdown.js +++ b/framework/core/js/forum/src/components/NotificationsDropdown.js @@ -25,7 +25,7 @@ export default class NotificationsDropdown extends Component { data-toggle="dropdown" onclick={this.onclick.bind(this)}> {unread || icon('bell')} - Notifications + {app.trans('core.notifications')}
    {this.showing ? NotificationList.component() : ''} diff --git a/framework/core/js/forum/src/components/PostEdited.js b/framework/core/js/forum/src/components/PostEdited.js index a0def5d12..4ff04b6fe 100644 --- a/framework/core/js/forum/src/components/PostEdited.js +++ b/framework/core/js/forum/src/components/PostEdited.js @@ -1,6 +1,7 @@ import Component from 'flarum/Component'; import icon from 'flarum/helpers/icon'; import humanTime from 'flarum/utils/humanTime'; +import extractText from 'flarum/utils/extractText'; /** * The `PostEdited` component displays information about when and by whom a post @@ -14,7 +15,7 @@ export default class PostEdited extends Component { view() { const post = this.props.post; const editUser = post.editUser(); - const title = 'Edited ' + (editUser ? 'by ' + editUser.username() + ' ' : '') + humanTime(post.editTime()); + const title = extractText(app.trans('core.post_edited', {user: editUser, ago: humanTime(post.editTime())})); return ( {icon('pencil')} diff --git a/framework/core/js/forum/src/components/PostMeta.js b/framework/core/js/forum/src/components/PostMeta.js index d02eeebce..ef86c97ca 100644 --- a/framework/core/js/forum/src/components/PostMeta.js +++ b/framework/core/js/forum/src/components/PostMeta.js @@ -33,7 +33,7 @@ export default class PostMeta extends Component {
    - Post #{post.number()}{' '} + {app.trans('core.post_number', {number: post.number()})}{' '} {fullTime(time)} {touch ? {permalink} diff --git a/framework/core/js/forum/src/components/PostStream.js b/framework/core/js/forum/src/components/PostStream.js index 6e1f4b58d..aa81bbb79 100644 --- a/framework/core/js/forum/src/components/PostStream.js +++ b/framework/core/js/forum/src/components/PostStream.js @@ -205,7 +205,7 @@ class PostStream extends mixin(Component, evented) { if (dt > 1000 * 60 * 60 * 24 * 4) { content = [
    - {moment.duration(dt).humanize()} later + {app.trans('core.period_later', {period: moment.duration(dt).humanize()})}
    , content ]; diff --git a/framework/core/js/forum/src/components/PostStreamScrubber.js b/framework/core/js/forum/src/components/PostStreamScrubber.js index 51f1b0b90..66dae0502 100644 --- a/framework/core/js/forum/src/components/PostStreamScrubber.js +++ b/framework/core/js/forum/src/components/PostStreamScrubber.js @@ -71,12 +71,10 @@ export default class PostStreamScrubber extends Component { const unreadCount = this.props.stream.discussion.unreadCount(); const unreadPercent = Math.min(this.count() - this.index, unreadCount) / this.count(); - const viewing = [ - {retain || formatNumber(this.visibleIndex())}, - ' of ', - {formatNumber(this.count())}, - ' posts ' - ]; + const viewing = app.trans('core.viewing_posts', { + index: {retain || formatNumber(this.visibleIndex())}, + count: {formatNumber(this.count())} + }); function styleUnread(element, isInitialized, context) { const $element = $(element); @@ -103,7 +101,7 @@ export default class PostStreamScrubber extends Component {
    - {icon('angle-double-up')} Original Post + {icon('angle-double-up')} {app.trans('core.original_post')}
    @@ -118,12 +116,12 @@ export default class PostStreamScrubber extends Component {
    - {formatNumber(unreadCount)} unread + {app.trans('core.unread_posts', {count: unreadCount})}
    - {icon('angle-double-down')} Now + {icon('angle-double-down')} {app.trans('core.now')}
    diff --git a/framework/core/js/forum/src/components/PostedActivity.js b/framework/core/js/forum/src/components/PostedActivity.js index 7ebc10255..8f3aff34f 100644 --- a/framework/core/js/forum/src/components/PostedActivity.js +++ b/framework/core/js/forum/src/components/PostedActivity.js @@ -15,7 +15,7 @@ export default class PostedActivity extends Activity { description() { const post = this.props.activity.subject(); - return post.number() === 1 ? 'Started a discussion' : 'Posted a reply'; + return app.trans(post.number() === 1 ? 'core.started_a_discussion' : 'core.posted_a_reply'); } content() { diff --git a/framework/core/js/forum/src/components/ReplyComposer.js b/framework/core/js/forum/src/components/ReplyComposer.js index 1f6795792..684fcebdb 100644 --- a/framework/core/js/forum/src/components/ReplyComposer.js +++ b/framework/core/js/forum/src/components/ReplyComposer.js @@ -16,9 +16,9 @@ export default class ReplyComposer extends ComposerBody { static initProps(props) { super.initProps(props); - props.placeholder = props.placeholder || 'Write a Reply...'; - props.submitLabel = props.submitLabel || 'Post Reply'; - props.confirmExit = props.confirmExit || 'You have not posted your reply. Do you wish to discard it?'; + props.placeholder = props.placeholder || app.trans('core.write_a_reply'); + props.submitLabel = props.submitLabel || app.trans('core.post_reply'); + props.confirmExit = props.confirmExit || app.trans('core.confirm_discard_reply'); } headerItems() { @@ -66,7 +66,7 @@ export default class ReplyComposer extends ComposerBody { // transition to their new post when clicked. let alert; const viewButton = Button.component({ - children: 'View', + children: app.trans('core.view'), onclick: () => { m.route(app.route.post(post)); app.alerts.dismiss(alert); @@ -75,7 +75,7 @@ export default class ReplyComposer extends ComposerBody { app.alerts.show( alert = new Alert({ type: 'success', - message: 'Your reply was posted.', + message: app.trans('reply_posted'), controls: [viewButton] }) ); diff --git a/framework/core/js/forum/src/components/ReplyPlaceholder.js b/framework/core/js/forum/src/components/ReplyPlaceholder.js index 79b9b0e91..a5b2005bb 100644 --- a/framework/core/js/forum/src/components/ReplyPlaceholder.js +++ b/framework/core/js/forum/src/components/ReplyPlaceholder.js @@ -25,7 +25,7 @@ export default class ReplyPlaceholder extends Component {
    {avatar(app.session.user, {className: 'PostUser-avatar'})}{' '} - Write a Reply... + {app.trans('core.write_a_reply')}
    ); diff --git a/framework/core/js/forum/src/components/Search.js b/framework/core/js/forum/src/components/Search.js index 88ad7fec5..396fe1dd4 100644 --- a/framework/core/js/forum/src/components/Search.js +++ b/framework/core/js/forum/src/components/Search.js @@ -82,7 +82,7 @@ export default class Search extends Component { })}>
    this.hasFocus = true} diff --git a/framework/core/js/forum/src/components/SessionDropdown.js b/framework/core/js/forum/src/components/SessionDropdown.js index 1ce2dd53f..e0f5ceeb1 100644 --- a/framework/core/js/forum/src/components/SessionDropdown.js +++ b/framework/core/js/forum/src/components/SessionDropdown.js @@ -47,7 +47,7 @@ export default class SessionDropdown extends Dropdown { items.add('profile', LinkButton.component({ icon: 'user', - children: 'Profile', + children: app.trans('core.profile'), href: app.route.user(user) }), 100 @@ -56,7 +56,7 @@ export default class SessionDropdown extends Dropdown { items.add('settings', LinkButton.component({ icon: 'cog', - children: 'Settings', + children: app.trans('core.settings'), href: app.route('settings') }), 50 @@ -66,7 +66,7 @@ export default class SessionDropdown extends Dropdown { items.add('administration', LinkButton.component({ icon: 'wrench', - children: 'Administration', + children: app.trans('core.administration'), href: app.forum.attribute('baseUrl') + '/admin', target: '_blank', config: () => {} @@ -80,7 +80,7 @@ export default class SessionDropdown extends Dropdown { items.add('logOut', Button.component({ icon: 'sign-out', - children: 'Log Out', + children: app.trans('core.log_out'), onclick: app.session.logout.bind(app.session) }), -100 diff --git a/framework/core/js/forum/src/components/SettingsPage.js b/framework/core/js/forum/src/components/SettingsPage.js index 66d228dca..0dcd81e20 100644 --- a/framework/core/js/forum/src/components/SettingsPage.js +++ b/framework/core/js/forum/src/components/SettingsPage.js @@ -18,7 +18,7 @@ export default class SettingsPage extends UserPage { super(...args); this.init(app.session.user); - app.setTitle('Settings'); + app.setTitle(app.trans('core.settings')); app.drawer.hide(); } @@ -40,7 +40,7 @@ export default class SettingsPage extends UserPage { items.add('account', FieldSet.component({ - label: 'Account', + label: app.trans('core.account'), className: 'Settings-account', children: this.accountItems().toArray() }) @@ -48,7 +48,7 @@ export default class SettingsPage extends UserPage { items.add('notifications', FieldSet.component({ - label: 'Notifications', + label: app.trans('core.notifications'), className: 'Settings-notifications', children: [NotificationGrid.component({user: this.user})] }) @@ -56,7 +56,7 @@ export default class SettingsPage extends UserPage { items.add('privacy', FieldSet.component({ - label: 'Privacy', + label: app.trans('core.privacy'), className: 'Settings-privacy', children: this.privacyItems().toArray() }) @@ -75,7 +75,7 @@ export default class SettingsPage extends UserPage { items.add('changePassword', Button.component({ - children: 'Change Password', + children: app.trans('core.change_password'), className: 'Button', onclick: () => app.modal.show(new ChangePasswordModal()) }) @@ -83,7 +83,7 @@ export default class SettingsPage extends UserPage { items.add('changeEmail', Button.component({ - children: 'Change Email', + children: app.trans('core.change_email'), className: 'Button', onclick: () => app.modal.show(new ChangeEmailModal()) }) @@ -91,7 +91,7 @@ export default class SettingsPage extends UserPage { items.add('deleteAccount', Button.component({ - children: 'Delete Account', + children: app.trans('core.delete_account'), className: 'Button Button--danger', onclick: () => app.modal.show(new DeleteAccountModal()) }) @@ -131,7 +131,7 @@ export default class SettingsPage extends UserPage { items.add('discloseOnline', Switch.component({ - children: 'Allow others to see when I am online', + children: app.trans('disclose_online'), state: this.user.preferences().discloseOnline, onchange: (value, component) => { this.user.pushAttributes({lastSeenTime: null}); diff --git a/framework/core/js/forum/src/components/SignUpModal.js b/framework/core/js/forum/src/components/SignUpModal.js index 57ccc9bb2..db0d46b11 100644 --- a/framework/core/js/forum/src/components/SignUpModal.js +++ b/framework/core/js/forum/src/components/SignUpModal.js @@ -49,7 +49,7 @@ export default class SignUpModal extends Modal { } title() { - return 'Sign Up'; + return app.trans('core.sign_up'); } content() { @@ -67,21 +67,21 @@ export default class SignUpModal extends Modal { const body = [(
    -
    -
    - @@ -91,7 +91,7 @@ export default class SignUpModal extends Modal {
    @@ -111,13 +111,21 @@ export default class SignUpModal extends Modal {
    {avatar(user)} -

    Welcome, {user.username()}!

    +

    {app.trans('core.welcome_user', {user})}

    {user.isConfirmed() ? [ -

    We've sent a confirmation email to {user.email()}. If it doesn't arrive soon, check your spam folder.

    , -

    Go to {emailProviderName}

    +

    {app.trans('core.confirmation_email_sent', {email: user.email()})}

    , +

    + + {app.trans('core.go_to', {location: emailProviderName})} + +

    ] : ( -

    +

    + +

    )}
    @@ -130,8 +138,8 @@ export default class SignUpModal extends Modal { footer() { return [

    - Already have an account?{' '} - Log In + {app.trans('core.before_log_in_link')}{' '} + {app.trans('core.log_in')}

    ]; } diff --git a/framework/core/js/forum/src/components/TerminalPost.js b/framework/core/js/forum/src/components/TerminalPost.js index 148fa72e0..268e15ab0 100644 --- a/framework/core/js/forum/src/components/TerminalPost.js +++ b/framework/core/js/forum/src/components/TerminalPost.js @@ -20,9 +20,10 @@ export default class TerminalPost extends Component { return ( - {username(user)}{' '} - {lastPost ? 'replied ' : 'started '} - {humanTime(time)} + {app.trans('core.discussion_' + (lastPost ? 'replied' : 'started'), { + user, + ago: humanTime(time) + })} ); } diff --git a/framework/core/js/forum/src/components/TextEditor.js b/framework/core/js/forum/src/components/TextEditor.js index c748fba06..93aa57014 100644 --- a/framework/core/js/forum/src/components/TextEditor.js +++ b/framework/core/js/forum/src/components/TextEditor.js @@ -26,12 +26,6 @@ export default class TextEditor extends Component { this.value = m.prop(this.props.value || ''); } - static initProps(props) { - super.initProps(props); - - props.submitLabel = props.submitLabel || 'Submit'; - } - view() { return (
    diff --git a/framework/core/js/forum/src/components/UserBio.js b/framework/core/js/forum/src/components/UserBio.js index f5bb66411..e44d8a5d4 100644 --- a/framework/core/js/forum/src/components/UserBio.js +++ b/framework/core/js/forum/src/components/UserBio.js @@ -1,4 +1,5 @@ import Component from 'flarum/Component'; +import LoadingIndicator from 'flarum/components/LoadingIndicator'; import classList from 'flarum/utils/classList'; /** @@ -29,19 +30,19 @@ export default class UserBio extends Component { let content; if (this.editing) { - content =