diff --git a/app/scenes/Search/Search.js b/app/scenes/Search/Search.js index 68819db05e..a61df472a6 100644 --- a/app/scenes/Search/Search.js +++ b/app/scenes/Search/Search.js @@ -7,6 +7,7 @@ import { PlusIcon } from "outline-icons"; import queryString from "query-string"; import * as React from "react"; import ReactDOM from "react-dom"; +import { withTranslation, Trans, type TFunction } from "react-i18next"; import keydown from "react-keydown"; import { withRouter, Link } from "react-router-dom"; import type { RouterHistory, Match } from "react-router-dom"; @@ -44,6 +45,7 @@ type Props = { documents: DocumentsStore, users: UsersStore, notFound: ?boolean, + t: TFunction, }; @observer @@ -67,7 +69,7 @@ class Search extends React.Component { } } - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps: Props) { if (prevProps.location.search !== this.props.location.search) { this.handleQueryChange(); } @@ -81,7 +83,7 @@ class Search extends React.Component { this.props.history.goBack(); } - handleKeyDown = (ev) => { + handleKeyDown = (ev: SyntheticKeyboardEvent<>) => { if (ev.key === "Enter") { this.fetchResults(); return; @@ -124,7 +126,12 @@ class Search extends React.Component { this.fetchResultsDebounced(); }; - handleFilterChange = (search) => { + handleFilterChange = (search: { + collectionId?: ?string, + userId?: ?string, + dateFilter?: ?string, + includeArchived?: ?string, + }) => { this.props.history.replace({ pathname: this.props.location.pathname, search: queryString.stringify({ @@ -170,7 +177,7 @@ class Search extends React.Component { get title() { const query = this.query; - const title = "Search"; + const title = this.props.t("Search"); if (query) return `${query} – ${title}`; return title; } @@ -231,20 +238,19 @@ class Search extends React.Component { trailing: true, }); - updateLocation = (query) => { + updateLocation = (query: string) => { this.props.history.replace({ pathname: searchUrl(query), search: this.props.location.search, }); }; - setFirstDocumentRef = (ref) => { - // $FlowFixMe + setFirstDocumentRef = (ref: any) => { this.firstDocument = ref; }; render() { - const { documents, notFound, location } = this.props; + const { documents, notFound, location, t } = this.props; const results = documents.searchResults(this.query); const showEmpty = !this.isLoading && this.query && results.length === 0; const showShortcutTip = @@ -256,12 +262,15 @@ class Search extends React.Component { {this.isLoading && } {notFound && (
-

Not Found

- We were unable to find the page you’re looking for. +

{t("Not Found")}

+ + {t("We were unable to find the page you’re looking for.")} +
)} { {showShortcutTip && ( - Use the {meta}+K shortcut to search from - anywhere in Outline + + Use the {{ meta }}+K shortcut to search from + anywhere in your knowledge base + )} @@ -304,8 +315,10 @@ class Search extends React.Component { - No documents found for your search filters.
- Create a new document? + + No documents found for your search filters.
+ Create a new document? +
{this.collectionId ? ( @@ -314,14 +327,14 @@ class Search extends React.Component { icon={} primary > - New doc + {t("New doc")} ) : ( )}   
@@ -414,4 +427,6 @@ const Filters = styled(Flex)` } `; -export default withRouter(inject("documents")(Search)); +export default withTranslation()( + withRouter(inject("documents")(Search)) +); diff --git a/app/scenes/Search/components/SearchField.js b/app/scenes/Search/components/SearchField.js index 440627c3e7..c4425f35f4 100644 --- a/app/scenes/Search/components/SearchField.js +++ b/app/scenes/Search/components/SearchField.js @@ -8,6 +8,7 @@ import { type Theme } from "types"; type Props = { onChange: (string) => void, defaultValue?: string, + placeholder?: string, theme: Theme, }; @@ -44,7 +45,7 @@ class SearchField extends React.Component { ref={(ref) => (this.input = ref)} onChange={this.handleChange} spellCheck="false" - placeholder="Search…" + placeholder={this.props.placeholder} type="search" autoFocus />