From ac4e9909fa4f3f6c6a0d1e537d6039115d07a5e0 Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Thu, 22 Jun 2017 06:30:03 -0400
Subject: Fixed incorrect formatting of numbers and plural words (#6696)

* Fixed incorrect formatting of numbers and plural words

* Removed unused i18n strings

* Fixed eslint errors
---
 .../commented_on_files_message.jsx                 | 42 +++++++++++++---------
 1 file changed, 26 insertions(+), 16 deletions(-)

(limited to 'webapp/components/post_view/commented_on_files_message/commented_on_files_message.jsx')

diff --git a/webapp/components/post_view/commented_on_files_message/commented_on_files_message.jsx b/webapp/components/post_view/commented_on_files_message/commented_on_files_message.jsx
index a09b2b156..a8c6845c8 100644
--- a/webapp/components/post_view/commented_on_files_message/commented_on_files_message.jsx
+++ b/webapp/components/post_view/commented_on_files_message/commented_on_files_message.jsx
@@ -1,9 +1,9 @@
 // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
 // See License.txt for license information.
 
+import PropTypes from 'prop-types';
 import React from 'react';
-
-import * as Utils from 'utils/utils.jsx';
+import {FormattedMessage} from 'react-intl';
 
 export default class CommentedOnFilesMessage extends React.PureComponent {
     static propTypes = {
@@ -11,19 +11,19 @@ export default class CommentedOnFilesMessage extends React.PureComponent {
         /*
          * The id of the post that was commented on
          */
-        parentPostId: React.PropTypes.string.isRequired,
+        parentPostId: PropTypes.string.isRequired,
 
         /*
          * An array of file metadata for the parent post
          */
-        fileInfos: React.PropTypes.arrayOf(React.PropTypes.object),
+        fileInfos: PropTypes.arrayOf(PropTypes.object),
 
-        actions: React.PropTypes.shape({
+        actions: PropTypes.shape({
 
             /*
              * Function to get file metadata for a post
              */
-            getFilesForPost: React.PropTypes.func.isRequired
+            getFilesForPost: PropTypes.func.isRequired
         }).isRequired
     }
 
@@ -34,18 +34,28 @@ export default class CommentedOnFilesMessage extends React.PureComponent {
     }
 
     render() {
-        let message = ' ';
-
-        if (this.props.fileInfos && this.props.fileInfos.length > 0) {
-            message = this.props.fileInfos[0].name;
+        if (!this.props.fileInfos || this.props.fileInfos.length === 0) {
+            return null;
+        }
 
-            if (this.props.fileInfos.length === 2) {
-                message += Utils.localizeMessage('post_body.plusOne', ' plus 1 other file');
-            } else if (this.props.fileInfos.length > 2) {
-                message += Utils.localizeMessage('post_body.plusMore', ' plus {count} other files').replace('{count}', (this.props.fileInfos.length - 1).toString());
-            }
+        let plusMore = null;
+        if (this.props.fileInfos.length > 1) {
+            plusMore = (
+                <FormattedMessage
+                    id='post_body.plusMore'
+                    defaultMessage=' plus {count, number} other {count, plural, one {file} other {files}}'
+                    values={{
+                        count: this.props.fileInfos.length
+                    }}
+                />
+            );
         }
 
-        return <span>{message}</span>;
+        return (
+            <span>
+                {this.props.fileInfos[0].name}
+                {plusMore}
+            </span>
+        );
     }
 }
-- 
cgit v1.2.3-1-g7c22

