Yuki Takei 7 лет назад
Родитель
Сommit
d832f8e4d5

+ 24 - 0
resource/locales/en-US/translation.json

@@ -172,6 +172,30 @@
     }
     }
   },
   },
 
 
+  "search_help": {
+    "title": "Searching Help",
+    "and": {
+      "syntax help": "divide with space",
+      "desc": "Search pages that include both {{word1}}, {{word2}} in the title or body"
+    },
+    "exclude": {
+      "desc": "Exclude pages that include {{word}} in the title or body"
+    },
+    "phrase": {
+      "syntax help": "surround with double quotes",
+      "desc": "Search pages that include the phrase \"{{phrase}}\""
+    },
+    "prefix": {
+      "desc": "Search only the pages that the title start with {{path}}"
+    },
+    "exclude_prefix": {
+      "desc": "Exclude the pages that the title start with {{path}}"
+    }
+  },
+  "search": {
+    "search page bodies": "Hit [Enter] key to full-text search"
+  },
+
   "page_page": {
   "page_page": {
       "notice": {
       "notice": {
           "version": "This is not the current version.",
           "version": "This is not the current version.",

+ 24 - 0
resource/locales/ja/translation.json

@@ -190,6 +190,30 @@
     }
     }
   },
   },
 
 
+  "search_help": {
+    "title": "検索のヘルプ",
+    "and": {
+      "syntax help": "スペース区切り",
+      "desc": "ページ名 or 本文に {{word1}}, {{word2}} の両方を含むページを検索"
+    },
+    "exclude": {
+      "desc": "ページ名 or 本文に {{word}} を含むページを除外"
+    },
+    "phrase": {
+      "syntax help": "ダブルクォートで囲う",
+      "desc": "{{phrase}} という文章を含むページを検索"
+    },
+    "prefix": {
+      "desc": "ページ名が {{path}} から始まるページに絞る"
+    },
+    "exclude_prefix": {
+      "desc": "ページ名が {{path}} から始まるページを除外"
+    }
+  },
+  "search": {
+    "search page bodies": "[Enter] キー押下で全文検索"
+  },
+
   "page_page": {
   "page_page": {
       "notice": {
       "notice": {
           "version": "これは現在の版ではありません。",
           "version": "これは現在の版ではありません。",

+ 1 - 1
src/client/js/app.js

@@ -274,7 +274,7 @@ if (!pageRevisionId && draft != null) {
 const componentMappings = {
 const componentMappings = {
   'search-top': <I18nextProvider i18n={i18n}><HeaderSearchBox crowi={crowi} /></I18nextProvider>,
   'search-top': <I18nextProvider i18n={i18n}><HeaderSearchBox crowi={crowi} /></I18nextProvider>,
   'search-sidebar': <HeaderSearchBox crowi={crowi} />,
   'search-sidebar': <HeaderSearchBox crowi={crowi} />,
-  'search-page': <SearchPage crowi={crowi} crowiRenderer={crowiRenderer} />,
+  'search-page': <I18nextProvider i18n={i18n}><SearchPage crowi={crowi} crowiRenderer={crowiRenderer} /></I18nextProvider>,
 
 
   //'revision-history': <PageHistory pageId={pageId} />,
   //'revision-history': <PageHistory pageId={pageId} />,
   'seen-user-list': <SeenUserList pageId={pageId} crowi={crowi} />,
   'seen-user-list': <SeenUserList pageId={pageId} crowi={crowi} />,

+ 26 - 8
src/client/js/components/SearchForm.js

@@ -38,23 +38,39 @@ export default class SearchForm extends React.Component {
   }
   }
 
 
   getHelpElement() {
   getHelpElement() {
+    const t = this.props.t;
+
     return (
     return (
       <table className="table m-1 search-help">
       <table className="table m-1 search-help">
         <caption className="text-left text-primary p-2 mb-2">
         <caption className="text-left text-primary p-2 mb-2">
-          <h5 className="m-1"><i className="icon-magnifier pr-2 mb-2"/>Search Help</h5>
+          <h5 className="m-1"><i className="icon-magnifier pr-2 mb-2"/>{ t('search_help.title') }</h5>
         </caption>
         </caption>
         <tbody>
         <tbody>
           <tr>
           <tr>
-            <td className="text-right mt-0 pr-2 p-1"><code>keyword</code></td>
-            <th className="mr-2"><h6 className="pr-2 m-0 pt-1">記事名 or 本文に<samp>"keyword"</samp>を含む</h6></th>
+            <th className="text-right pt-2">
+              <code>word1</code> <code>word2</code><br></br>
+              <small>({ t('search_help.and.syntax help') })</small>
+            </th>
+            <td><h6 className="m-0 pt-1">{ t('search_help.and.desc', { word1: 'word1', word2: 'word2' }) }</h6></td>
+          </tr>
+          <tr>
+            <th className="text-right pt-2">
+              <code>"This is GROWI"</code><br></br>
+              <small>({ t('search_help.phrase.syntax help') })</small>
+            </th>
+            <td><h6 className="m-0 pt-1">{ t('search_help.phrase.desc', { phrase: 'This is GROWI' }) }</h6></td>
+          </tr>
+          <tr>
+            <th className="text-right pt-2"><code>-keyword</code></th>
+            <td><h6 className="m-0 pt-1">{ t('search_help.exclude.desc', { word: 'keyword' }) }</h6></td>
           </tr>
           </tr>
           <tr>
           <tr>
-            <td className="text-right mt-0 pr-2 p-1"><code>a b</code></td>
-            <th><h6 className="m-0 pt-1">文字列<samp>"a"</samp>と<samp>"b"</samp>を含む (スペース区切り)</h6></th>
+            <th className="text-right pt-2"><code>prefix:/user/</code></th>
+            <td><h6 className="m-0 pt-1">{ t('search_help.prefix.desc', { path: '/user/' }) }</h6></td>
           </tr>
           </tr>
           <tr>
           <tr>
-            <td className="text-right mt-0 pr-2 p-1"><code>-keyword</code></td>
-            <th><h6 className="m-0 pt-1">文字列<samp>"keyword"</samp>を含まない</h6></th>
+            <th className="text-right pt-2"><code>-prefix:/user/</code></th>
+            <td><h6 className="m-0 pt-1">{ t('search_help.exclude_prefix.desc', { path: '/user/' }) }</h6></td>
           </tr>
           </tr>
         </tbody>
         </tbody>
       </table>
       </table>
@@ -62,9 +78,10 @@ export default class SearchForm extends React.Component {
   }
   }
 
 
   render() {
   render() {
+    const t = this.props.t;
     const emptyLabel = (this.state.searchError !== null)
     const emptyLabel = (this.state.searchError !== null)
       ? 'Error on searching.'
       ? 'Error on searching.'
-      : 'No matches found on title... Hit [Enter] key so that search on contents.';
+      : t('search.search page bodies');
 
 
     return (
     return (
       <SearchTypeahead
       <SearchTypeahead
@@ -83,6 +100,7 @@ export default class SearchForm extends React.Component {
 }
 }
 
 
 SearchForm.propTypes = {
 SearchForm.propTypes = {
+  t: PropTypes.func.isRequired,               // i18next
   crowi: PropTypes.object.isRequired,
   crowi: PropTypes.object.isRequired,
   keyword: PropTypes.string,
   keyword: PropTypes.string,
   onSubmit: PropTypes.func.isRequired,
   onSubmit: PropTypes.func.isRequired,

+ 5 - 2
src/client/js/components/SearchPage.js

@@ -2,11 +2,12 @@
 
 
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
+import { translate } from 'react-i18next';
 
 
 import SearchPageForm from './SearchPage/SearchPageForm';
 import SearchPageForm from './SearchPage/SearchPageForm';
 import SearchResult from './SearchPage/SearchResult';
 import SearchResult from './SearchPage/SearchResult';
 
 
-export default class SearchPage extends React.Component {
+class SearchPage extends React.Component {
 
 
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
@@ -92,7 +93,7 @@ export default class SearchPage extends React.Component {
     return (
     return (
       <div>
       <div>
         <div className="search-page-input">
         <div className="search-page-input">
-          <SearchPageForm
+          <SearchPageForm t={this.props.t}
             crowi={this.props.crowi}
             crowi={this.props.crowi}
             onSearchFormChanged={this.search}
             onSearchFormChanged={this.search}
             keyword={this.state.searchingKeyword}
             keyword={this.state.searchingKeyword}
@@ -110,6 +111,7 @@ export default class SearchPage extends React.Component {
 }
 }
 
 
 SearchPage.propTypes = {
 SearchPage.propTypes = {
+  t: PropTypes.func.isRequired,               // i18next
   crowi: PropTypes.object.isRequired,
   crowi: PropTypes.object.isRequired,
   crowiRenderer: PropTypes.object.isRequired,
   crowiRenderer: PropTypes.object.isRequired,
   query: PropTypes.object,
   query: PropTypes.object,
@@ -120,3 +122,4 @@ SearchPage.defaultProps = {
   searchError: null,
   searchError: null,
 };
 };
 
 
+export default translate()(SearchPage);

+ 2 - 1
src/client/js/components/SearchPage/SearchPageForm.js

@@ -35,7 +35,7 @@ export default class SearchPageForm extends React.Component {
   render() {
   render() {
     return <FormGroup>
     return <FormGroup>
       <InputGroup>
       <InputGroup>
-        <SearchForm
+        <SearchForm t={this.props.t}
           crowi={this.props.crowi}
           crowi={this.props.crowi}
           onSubmit={this.search}
           onSubmit={this.search}
           keyword={this.state.searchedKeyword}
           keyword={this.state.searchedKeyword}
@@ -52,6 +52,7 @@ export default class SearchPageForm extends React.Component {
 }
 }
 
 
 SearchPageForm.propTypes = {
 SearchPageForm.propTypes = {
+  t: PropTypes.func.isRequired,               // i18next
   crowi: PropTypes.object.isRequired,
   crowi: PropTypes.object.isRequired,
   keyword: PropTypes.string,
   keyword: PropTypes.string,
   onSearchFormChanged: PropTypes.func.isRequired,
   onSearchFormChanged: PropTypes.func.isRequired,

+ 0 - 5
src/client/styles/scss/_search.scss

@@ -47,11 +47,6 @@
   }
   }
 }
 }
 
 
-table.search-help > tbody > tr {
-  th, td {
-    border-top: none;
-  }
-}
 
 
 // top and sidebar input styles
 // top and sidebar input styles
 .search-top, .search-sidebar {
 .search-top, .search-sidebar {