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

Reader: Use localize() instead of i18n mixin #13759

Merged
merged 8 commits into from
May 10, 2017
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
8 changes: 4 additions & 4 deletions client/reader/feed-error/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import React from 'react';
import i18n from 'i18n-calypso';
import i18n, { localize } from 'i18n-calypso';

/**
* Internal dependencies
Expand Down Expand Up @@ -34,11 +34,11 @@ const FeedError = React.createClass( {
render() {
const action = ( <a className="empty-content__action button is-primary"
onClick={ this.recordAction }
href="/read/search">{ this.translate( 'Find Sites to Follow' ) }</a>),
href="/read/search">{ this.props.translate( 'Find Sites to Follow' ) }</a>),
secondaryAction = (
<a className="empty-content__action button"
onClick={ this.recordSecondaryAction }
href="/discover">{ this.translate( 'Explore Discover' ) }</a> );
href="/discover">{ this.props.translate( 'Explore Discover' ) }</a> );

return (
<ReaderMain>
Expand All @@ -62,4 +62,4 @@ FeedError.propTypes = {
sidebarTitle: React.PropTypes.string
};

export default FeedError;
export default localize( FeedError );
12 changes: 6 additions & 6 deletions client/reader/following-edit/empty.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import React from 'react';
import i18n from 'i18n-calypso';
import { localize } from 'i18n-calypso';

/**
* Internal dependencies
Expand Down Expand Up @@ -30,23 +30,23 @@ const FollowingEditEmptyContent = React.createClass( {
render() {
const action = ( <a className="empty-content__action button is-primary"
onClick={ this.recordAction }
href="/read/search">{ this.translate( 'Find Sites to Follow' ) }</a>),
href="/read/search">{ this.props.translate( 'Find Sites to Follow' ) }</a>),
secondaryAction = (
<a className="empty-content__action button"
onClick={ this.recordSecondaryAction }
href="/discover">{ this.translate( 'Explore Discover' ) }</a> );
href="/discover">{ this.props.translate( 'Explore Discover' ) }</a> );

return (
<EmptyContent
action={ action }
secondaryAction={ secondaryAction }
title={ i18n.translate( 'You haven\'t followed any sites yet' ) }
line={ i18n.translate( 'Search for a site or explore Discover.' ) }
title={ this.props.translate( 'You haven\'t followed any sites yet' ) }
line={ this.props.translate( 'Search for a site or explore Discover.' ) }
illustration={ '/calypso/images/drake/drake-404.svg' }
illustrationWidth={ 500 }
/>
);
}
} );

export default FollowingEditEmptyContent;
export default localize( FollowingEditEmptyContent );
7 changes: 4 additions & 3 deletions client/reader/following-edit/export-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import Blob from 'blob';
import { localize } from 'i18n-calypso';
import React from 'react';
import noop from 'lodash/noop';
import { saveAs } from 'browser-filesaver';
Expand Down Expand Up @@ -46,7 +47,7 @@ const FollowingExportButton = React.createClass( {
} );

if ( ! err && ! data.success ) {
err = new Error( this.translate( 'Error exporting Reader feed' ) );
err = new Error( this.props.translate( 'Error exporting Reader feed' ) );
}

if ( err ) {
Expand All @@ -64,10 +65,10 @@ const FollowingExportButton = React.createClass( {
compact
disabled={ this.state.disabled }
onClick={ this.onClick } >
{ this.translate( 'Export' ) }
{ this.props.translate( 'Export' ) }
</Button>
);
}
} );

export default FollowingExportButton;
export default localize( FollowingExportButton );
5 changes: 3 additions & 2 deletions client/reader/following-edit/import-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import React from 'react';
import { localize } from 'i18n-calypso';
import noop from 'lodash/noop';

/**
Expand Down Expand Up @@ -70,11 +71,11 @@ const FollowingImportButton = React.createClass( {
return (
<FilePicker accept=".xml,.opml" onPick={ this.onPick } >
<Button compact disabled={ this.state.disabled } >
{ this.translate( 'Import' ) }
{ this.props.translate( 'Import' ) }
</Button>
</FilePicker>
);
}
} );

export default FollowingImportButton;
export default localize( FollowingImportButton );
44 changes: 23 additions & 21 deletions client/reader/following-edit/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// External dependencies
import React from 'react';
import { localize } from 'i18n-calypso';
import times from 'lodash/times';
import trimStart from 'lodash/trimStart';
import Immutable from 'immutable';
Expand Down Expand Up @@ -374,15 +375,16 @@ const FollowingEdit = React.createClass( {

const url = this.state.lastError.URL;

return ( <Notice
status="is-error"
showDismiss={ true }
onDismissClick={ this.dismissError }>
{ this.translate( 'Sorry - there was a problem unfollowing {{strong}}%(url)s{{/strong}}.', {
components: { strong: <strong /> },
args: { url: url } } )
}
</Notice>
return (
<Notice
status="is-error"
showDismiss={ true }
onDismissClick={ this.dismissError }>
{ this.props.translate( 'Sorry - there was a problem unfollowing {{strong}}%(url)s{{/strong}}.', {
components: { strong: <strong /> },
args: { url: url } } )
}
</Notice>
);
},

Expand All @@ -395,9 +397,9 @@ const FollowingEdit = React.createClass( {
let errorMessage;

if ( lastError.info && lastError.info === 'already_subscribed' ) {
errorMessage = this.translate( 'You\'re already subscribed to that site.' );
errorMessage = this.props.translate( 'You\'re already subscribed to that site.' );
} else {
errorMessage = this.translate( 'Sorry, we couldn\'t find a feed for {{em}}%(url)s{{/em}}.', {
errorMessage = this.props.translate( 'Sorry, we couldn\'t find a feed for {{em}}%(url)s{{/em}}.', {
args: { url: this.state.searchString },
components: { em: <em/> }
} );
Expand All @@ -418,7 +420,7 @@ const FollowingEdit = React.createClass( {
return null;
}

const message = this.translate( 'Your Followed Sites list has been exported.' );
const message = this.props.translate( 'Your Followed Sites list has been exported.' );
return (
<Notice
key="notice-feed-export"
Expand All @@ -436,7 +438,7 @@ const FollowingEdit = React.createClass( {
return null;
}

const message = this.translate( '{{em}}%(name)s{{/em}} has been imported. Refresh this page to see the new sites you follow.', {
const message = this.props.translate( '{{em}}%(name)s{{/em}} has been imported. Refresh this page to see the new sites you follow.', {
args: { name: feedImport.fileName },
components: { em: <em/> }
} );
Expand All @@ -460,7 +462,7 @@ const FollowingEdit = React.createClass( {
return null;
}

const message = this.translate( 'Whoops, something went wrong. %(message)s. Please try again.', {
const message = this.props.translate( 'Whoops, something went wrong. %(message)s. Please try again.', {
args: { message: error.message }
} );
return (
Expand Down Expand Up @@ -516,9 +518,9 @@ const FollowingEdit = React.createClass( {
}

if ( this.state.windowWidth && this.state.windowWidth > 960 ) {
searchPlaceholder = this.translate( 'Search your followed sites' );
searchPlaceholder = this.props.translate( 'Search your followed sites' );
} else {
searchPlaceholder = this.translate( 'Search' );
searchPlaceholder = this.props.translate( 'Search' );
}

const containerClasses = classnames( {
Expand All @@ -529,7 +531,7 @@ const FollowingEdit = React.createClass( {
return (
<ReaderMain className={ containerClasses }>
<MobileBackToSidebar>
<h1>{ this.translate( 'Manage Followed Sites' ) }</h1>
<h1>{ this.props.translate( 'Manage Followed Sites' ) }</h1>
</MobileBackToSidebar>
{ this.renderFollowError() }
{ this.renderUnfollowError() }
Expand All @@ -543,7 +545,7 @@ const FollowingEdit = React.createClass( {
isSearchOpen={ this.state.isAddingOpen }
ref="feed-search" />

<SectionHeader className="following-edit__header" label={ this.translate( 'Sites' ) } count={ this.state.totalSubscriptions }>
<SectionHeader className="following-edit__header" label={ this.props.translate( 'Sites' ) } count={ this.state.totalSubscriptions }>
{ ! hasNoSubscriptions
? <FollowingExportButton
onExport={ this.handleFeedExport }
Expand All @@ -559,7 +561,7 @@ const FollowingEdit = React.createClass( {
? <Button
borderless
className="following-edit__search"
aria-label={ this.translate( 'Open Search', { context: 'button label' } ) }
aria-label={ this.props.translate( 'Open Search', { context: 'button label' } ) }
onClick={ this.toggleSearching }>
<Gridicon icon="search" />
</Button>
Expand All @@ -581,7 +583,7 @@ const FollowingEdit = React.createClass( {

{ this.state.isAttemptingFollow && ! this.state.lastError ? <SubscriptionPlaceholder key={ 'placeholder-add-feed' } /> : null }
{ subscriptionsToDisplay.length === 0 && this.props.search && ! this.state.isLoading
? <NoResults text={ this.translate( 'No subscriptions match that search.' ) } />
? <NoResults text={ this.props.translate( 'No subscriptions match that search.' ) } />
: <InfiniteList className="following-edit__sites"
items={ subscriptionsToDisplay }
lastPage={ this.state.isLastPage }
Expand All @@ -600,4 +602,4 @@ const FollowingEdit = React.createClass( {

} );

export default FollowingEdit;
export default localize( FollowingEdit );
5 changes: 3 additions & 2 deletions client/reader/following-edit/navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import React from 'react';
import { localize } from 'i18n-calypso';

var FollowingEditNavigation = React.createClass( {

Expand All @@ -13,7 +14,7 @@ var FollowingEditNavigation = React.createClass( {
return null;
}

return this.translate(
return this.props.translate(
'%(count)d site',
'%(count)d sites',
{
Expand All @@ -32,4 +33,4 @@ var FollowingEditNavigation = React.createClass( {
}
} );

export default FollowingEditNavigation;
export default localize( FollowingEditNavigation );
27 changes: 15 additions & 12 deletions client/reader/following-edit/notification-settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import React from 'react';
import { localize } from 'i18n-calypso';
import classnames from 'classnames';

/**
Expand Down Expand Up @@ -120,7 +121,7 @@ var FollowingEditNotificationSettings = React.createClass( {

return (
<div className="following-edit__notification-settings-error">
<FormInputValidation className="following-edit__notification-settings-error" isError text={ this.translate( 'Sorry, there was a problem changing your subscription settings.' ) } />
<FormInputValidation className="following-edit__notification-settings-error" isError text={ this.props.translate( 'Sorry, there was a problem changing your subscription settings.' ) } />
</div>
);
},
Expand All @@ -140,17 +141,19 @@ var FollowingEditNotificationSettings = React.createClass( {

if ( isExternal ) {
return (
<Card className="is-compact is-impossible-to-send-email following-edit__notification-settings-card" key={ 'notification-settings-comments-' + subscription.get( 'ID' ) }>
<p>{ this.translate( 'RSS feeds do not allow for email notifications.' ) }</p>
<Card className="is-compact is-impossible-to-send-email following-edit__notification-settings-card"
key={ 'notification-settings-comments-' + subscription.get( 'ID' ) }>
<p>{ this.props.translate( 'RSS feeds do not allow for email notifications.' ) }</p>
</Card>
);
}

if ( this.props.isEmailBlocked ) {
return (
<Card className="is-compact is-impossible-to-send-email following-edit__notification-settings-card" key={ 'notification-settings-comments-' + subscription.get( 'ID' ) }>
<p>{ this.translate( 'You have blocked all email updates from your subscribed blogs.' ) }</p>
<p>{ this.translate( 'You can change this in your {{settingsLink}}Notification Settings{{/settingsLink}}.',
<Card className="is-compact is-impossible-to-send-email following-edit__notification-settings-card"
key={ 'notification-settings-comments-' + subscription.get( 'ID' ) }>
<p>{ this.props.translate( 'You have blocked all email updates from your subscribed blogs.' ) }</p>
<p>{ this.props.translate( 'You can change this in your {{settingsLink}}Notification Settings{{/settingsLink}}.',
{
components: {
settingsLink: <a href="/me/notifications/subscriptions" />
Expand All @@ -165,22 +168,22 @@ var FollowingEditNotificationSettings = React.createClass( {
return (
<div>
<Card className={ postEmailClasses } key={ 'notification-settings-posts-' + subscription.get( 'ID' ) }>
<span>{ this.translate( 'Emails for new posts' ) }</span>
<span>{ this.props.translate( 'Emails for new posts' ) }</span>
<span className="following-edit__form-toggle-wrapper">
<span className="following-edit__form-toggle-status">{ isPostEmailActive ? 'on' : 'off' }</span>
<FormToggle id="following-edit__form-toggle-post-emails" onChange={ this.handlePostEmailToggle } checked={ isPostEmailActive } disabled={ false } />
</span>
{ isPostEmailActive ?
<SegmentedControl compact={ true }>
<ControlItem selected={ emailDeliveryFrequency === DELIVERY_FREQUENCY_INSTANTLY } onClick={ this.handleEmailFrequencyClick.bind( this, DELIVERY_FREQUENCY_INSTANTLY ) } key={ 'delivery-frequency-instant' }>{ this.translate( 'Instant' ) }</ControlItem>
<ControlItem selected={ emailDeliveryFrequency === DELIVERY_FREQUENCY_DAILY } onClick={ this.handleEmailFrequencyClick.bind( this, DELIVERY_FREQUENCY_DAILY ) } key={ 'delivery-frequency-daily' }>{ this.translate( 'Daily' ) }</ControlItem>
<ControlItem selected={ emailDeliveryFrequency === DELIVERY_FREQUENCY_WEEKLY } onClick={ this.handleEmailFrequencyClick.bind( this, DELIVERY_FREQUENCY_WEEKLY ) } key={ 'delivery-frequency-weekly' }>{ this.translate( 'Weekly' ) }</ControlItem>
<ControlItem selected={ emailDeliveryFrequency === DELIVERY_FREQUENCY_INSTANTLY } onClick={ this.handleEmailFrequencyClick.bind( this, DELIVERY_FREQUENCY_INSTANTLY ) } key={ 'delivery-frequency-instant' }>{ this.props.translate( 'Instant' ) }</ControlItem>
<ControlItem selected={ emailDeliveryFrequency === DELIVERY_FREQUENCY_DAILY } onClick={ this.handleEmailFrequencyClick.bind( this, DELIVERY_FREQUENCY_DAILY ) } key={ 'delivery-frequency-daily' }>{ this.props.translate( 'Daily' ) }</ControlItem>
<ControlItem selected={ emailDeliveryFrequency === DELIVERY_FREQUENCY_WEEKLY } onClick={ this.handleEmailFrequencyClick.bind( this, DELIVERY_FREQUENCY_WEEKLY ) } key={ 'delivery-frequency-weekly' }>{ this.props.translate( 'Weekly' ) }</ControlItem>
</SegmentedControl> : null }
{ this.renderPostEmailError() }
</Card>

<Card className={ commentEmailClasses } key={ 'notification-settings-comments-' + subscription.get( 'ID' ) }>
<span>{ this.translate( 'Emails for new comments' ) }</span>
<span>{ this.props.translate( 'Emails for new comments' ) }</span>
<span className="following-edit__form-toggle-wrapper">
<span className="following-edit__form-toggle-status">{ isCommentEmailActive ? 'on' : 'off' }</span>
<FormToggle id="following-edit__form-toggle-comment-emails" onChange={ this.handleCommentEmailToggle } checked={ isCommentEmailActive } disabled={ false } />
Expand All @@ -193,4 +196,4 @@ var FollowingEditNotificationSettings = React.createClass( {

} );

export default FollowingEditNotificationSettings;
export default localize( FollowingEditNotificationSettings );
9 changes: 5 additions & 4 deletions client/reader/following-edit/sort-controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import React from 'react';
import { localize } from 'i18n-calypso';
import noop from 'lodash/noop';

/**
Expand Down Expand Up @@ -30,14 +31,14 @@ const FollowingEditSortControls = React.createClass( {

return (
<div className="following-edit__sort-controls">
<label htmlFor="sort-control-select">{ this.translate( 'Sort by' ) }</label>
<label htmlFor="sort-control-select">{ this.props.translate( 'Sort by' ) }</label>
<select id="sort-control-select" ref="sortControlSelect" className="is-compact" onChange={ this.handleSelectChange } value={ sortOrder }>
<option value="date-followed">{ this.translate( 'By Date' ) }</option>
<option value="alpha">{ this.translate( 'By Name' ) }</option>
<option value="date-followed">{ this.props.translate( 'By Date' ) }</option>
<option value="alpha">{ this.props.translate( 'By Name' ) }</option>
</select>
</div>
);
}
} );

export default FollowingEditSortControls;
export default localize( FollowingEditSortControls );
5 changes: 3 additions & 2 deletions client/reader/following-edit/subscribe-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import React from 'react';
import { localize } from 'i18n-calypso';
import url from 'url';
import noop from 'lodash/noop';

Expand Down Expand Up @@ -148,7 +149,7 @@ var FollowingEditSubscribeForm = React.createClass( {
key="newSubscriptionSearch"
onSearch={ this.handleSearch }
onSearchClose={ this.handleSearchClose }
placeholder={ this.translate( 'Enter a site URL to follow', { context: 'field placeholder' } ) }
placeholder={ this.props.translate( 'Enter a site URL to follow', { context: 'field placeholder' } ) }
delaySearch={ false }
ref="followingEditSubscriptionSearch"
onKeyDown={ this.handleKeyDown }
Expand All @@ -162,4 +163,4 @@ var FollowingEditSubscribeForm = React.createClass( {

} );

export default FollowingEditSubscribeForm;
export default localize( FollowingEditSubscribeForm );
Loading