Merge pull request #2103 from dimofte/feature/datatables-i18n-search

datatable: add i18n for the search field
This commit is contained in:
Sacha Greif 2018-10-13 12:29:10 +09:00 committed by GitHub
commit b36209938d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -113,16 +113,28 @@ registerComponent('Datatable', Datatable, withCurrentUser);
DatatableAbove Component DatatableAbove Component
*/ */
const DatatableAbove = (props) => { const DatatableAbove = (props, { intl }) => {
const { collection, currentUser, showSearch, showNew, canInsert, value, updateQuery, options, newFormOptions } = props; const { collection, currentUser, showSearch, showNew, canInsert, value, updateQuery, options, newFormOptions } = props;
return ( return (
<div className="datatable-above"> <div className="datatable-above">
{showSearch && <input className="datatable-search form-control" placeholder="Search…" type="text" name="datatableSearchQuery" value={value} onChange={updateQuery} />} {showSearch && (
<input
className="datatable-search form-control"
placeholder={`${intl.formatMessage({ id: 'datatable.search', defaultMessage: 'Search' })}…`}
type="text"
name="datatableSearchQuery"
value={value}
onChange={updateQuery}
/>
)}
{showNew && canInsert && <Components.NewButton collection={collection} currentUser={currentUser} mutationFragmentName={options && options.fragmentName} {...newFormOptions}/>} {showNew && canInsert && <Components.NewButton collection={collection} currentUser={currentUser} mutationFragmentName={options && options.fragmentName} {...newFormOptions}/>}
</div> </div>
) )
} }
DatatableAbove.contextTypes = {
intl: intlShape,
};
registerComponent('DatatableAbove', DatatableAbove); registerComponent('DatatableAbove', DatatableAbove);
/* /*

View file

@ -131,6 +131,7 @@ addStrings('en', {
'cards.edit': 'Edit', 'cards.edit': 'Edit',
'datatable.new': 'New', 'datatable.new': 'New',
'datatable.edit': 'Edit', 'datatable.edit': 'Edit',
'datatable.search': 'Search',
'admin': 'Admin', 'admin': 'Admin',
'notifications': 'Notifications', 'notifications': 'Notifications',