From 01e43c3e5799b575a70798056945365ddf51f3ad Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 16 Nov 2016 17:20:52 +0100 Subject: Adding react-intl i18n to the frontend. No translations yet --- .../features/compose/components/compose_form.jsx | 8 +++++--- .../features/compose/components/navigation_bar.jsx | 9 +++++---- .../features/compose/components/reply_indicator.jsx | 14 ++++++-------- .../components/features/compose/components/search.jsx | 5 +++-- .../features/compose/components/suggestions_box.jsx | 9 +++++---- .../features/compose/components/upload_button.jsx | 7 +++++-- .../components/features/compose/components/upload_form.jsx | 11 +++++++---- 7 files changed, 36 insertions(+), 27 deletions(-) (limited to 'app/assets/javascripts/components/features/compose') diff --git a/app/assets/javascripts/components/features/compose/components/compose_form.jsx b/app/assets/javascripts/components/features/compose/components/compose_form.jsx index ead8e0008..5aa041f09 100644 --- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx @@ -8,6 +8,7 @@ import Autosuggest from 'react-autosuggest'; import AutosuggestAccountContainer from '../../compose/containers/autosuggest_account_container'; import { debounce } from 'react-decoration'; import UploadButtonContainer from '../containers/upload_button_container'; +import { injectIntl } from 'react-intl'; const getTokenForSuggestions = (str, caretPosition) => { let word; @@ -134,6 +135,7 @@ const ComposeForm = React.createClass({ }, render () { + const { intl } = this.props; let replyArea = ''; const disabled = this.props.is_submitting || this.props.is_uploading; @@ -142,7 +144,7 @@ const ComposeForm = React.createClass({ } const inputProps = { - placeholder: 'What is on your mind?', + placeholder: intl.formatMessage({ id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' }), value: this.props.text, onKeyUp: this.handleKeyUp, onChange: this.handleChange, @@ -167,7 +169,7 @@ const ComposeForm = React.createClass({ />
-
+
@@ -177,4 +179,4 @@ const ComposeForm = React.createClass({ }); -export default ComposeForm; +export default injectIntl(ComposeForm); diff --git a/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx b/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx index d2dae141f..4ba6d2290 100644 --- a/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx +++ b/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx @@ -1,9 +1,10 @@ import PureRenderMixin from 'react-addons-pure-render-mixin'; import ImmutablePropTypes from 'react-immutable-proptypes'; import Avatar from '../../../components/avatar'; -import IconButton from '../../../components/icon_button'; -import DisplayName from '../../../components/display_name'; -import { Link } from 'react-router'; +import IconButton from '../../../components/icon_button'; +import DisplayName from '../../../components/display_name'; +import { Link } from 'react-router'; +import { FormattedMessage } from 'react-intl'; const NavigationBar = React.createClass({ propTypes: { @@ -19,7 +20,7 @@ const NavigationBar = React.createClass({
{this.props.account.get('acct')} - Settings · Public timeline · Logout + · ·
); diff --git a/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx b/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx index 6298d3de9..4b34f09bf 100644 --- a/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx +++ b/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx @@ -3,11 +3,8 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import Avatar from '../../../components/avatar'; import IconButton from '../../../components/icon_button'; import DisplayName from '../../../components/display_name'; -import emojione from 'emojione'; - -emojione.imageType = 'png'; -emojione.sprites = false; -emojione.imagePathPNG = '/emoji/'; +import emojify from '../../../emoji'; +import { injectIntl } from 'react-intl'; const ReplyIndicator = React.createClass({ @@ -34,12 +31,13 @@ const ReplyIndicator = React.createClass({ }, render () { - let content = { __html: emojione.unicodeToImage(this.props.status.get('content')) }; + const { intl } = this.props; + const content = { __html: emojify(this.props.status.get('content')) }; return (
-
+
@@ -54,4 +52,4 @@ const ReplyIndicator = React.createClass({ }); -export default ReplyIndicator; +export default injectIntl(ReplyIndicator); diff --git a/app/assets/javascripts/components/features/compose/components/search.jsx b/app/assets/javascripts/components/features/compose/components/search.jsx index 37efbe5df..65df336cc 100644 --- a/app/assets/javascripts/components/features/compose/components/search.jsx +++ b/app/assets/javascripts/components/features/compose/components/search.jsx @@ -3,6 +3,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import Autosuggest from 'react-autosuggest'; import AutosuggestAccountContainer from '../containers/autosuggest_account_container'; import { debounce } from 'react-decoration'; +import { injectIntl } from 'react-intl'; const getSuggestionValue = suggestion => suggestion.value; @@ -94,7 +95,7 @@ const Search = React.createClass({ render () { const inputProps = { - placeholder: 'Search', + placeholder: this.props.intl.formatMessage({ id: 'search.placeholder', defaultMessage: 'Search' }), value: this.props.value, onChange: this.onChange, style: inputStyle @@ -125,4 +126,4 @@ const Search = React.createClass({ }); -export default Search; +export default injectIntl(Search); diff --git a/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx b/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx index 70c2fca6e..697902275 100644 --- a/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx +++ b/app/assets/javascripts/components/features/compose/components/suggestions_box.jsx @@ -1,6 +1,7 @@ -import PureRenderMixin from 'react-addons-pure-render-mixin'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import AccountContainer from '../../followers/containers/account_container'; +import AccountContainer from '../../followers/containers/account_container'; +import { FormattedMessage } from 'react-intl'; const outerStyle = { position: 'relative' @@ -66,13 +67,13 @@ const SuggestionsBox = React.createClass({ let nextLink = ''; if (accountIds.size > perWindow) { - nextLink =
Refresh; + nextLink = ; } return (
- Who to follow {nextLink} + {nextLink} {accountIds.skip(perWindow * this.state.index).take(perWindow).map(accountId => )} diff --git a/app/assets/javascripts/components/features/compose/components/upload_button.jsx b/app/assets/javascripts/components/features/compose/components/upload_button.jsx index 8289e0a09..cc251835f 100644 --- a/app/assets/javascripts/components/features/compose/components/upload_button.jsx +++ b/app/assets/javascripts/components/features/compose/components/upload_button.jsx @@ -1,5 +1,6 @@ import PureRenderMixin from 'react-addons-pure-render-mixin'; import IconButton from '../../../components/icon_button'; +import { injectIntl } from 'react-intl'; const UploadButton = React.createClass({ @@ -26,9 +27,11 @@ const UploadButton = React.createClass({ }, render () { + const { intl } = this.props; + return (
- +
); @@ -36,4 +39,4 @@ const UploadButton = React.createClass({ }); -export default UploadButton; +export default injectIntl(UploadButton); diff --git a/app/assets/javascripts/components/features/compose/components/upload_form.jsx b/app/assets/javascripts/components/features/compose/components/upload_form.jsx index eab504b48..72c2b9535 100644 --- a/app/assets/javascripts/components/features/compose/components/upload_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/upload_form.jsx @@ -1,6 +1,7 @@ -import PureRenderMixin from 'react-addons-pure-render-mixin'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import IconButton from '../../../components/icon_button'; +import IconButton from '../../../components/icon_button'; +import { injectIntl } from 'react-intl'; const UploadForm = React.createClass({ @@ -13,10 +14,12 @@ const UploadForm = React.createClass({ mixins: [PureRenderMixin], render () { + const { intl } = this.props; + const uploads = this.props.media.map(attachment => (
- +
)); @@ -30,4 +33,4 @@ const UploadForm = React.createClass({ }); -export default UploadForm; +export default injectIntl(UploadForm); -- cgit