Skip to content

Commit

Permalink
Merge pull request #6948 from jcaianirh/i18n-search
Browse files Browse the repository at this point in the history
CONSOLE-2428: i18n for search section of home nav
  • Loading branch information
openshift-merge-robot committed Oct 21, 2020
2 parents 44c2256 + 3a19480 commit 249f578
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
21 changes: 11 additions & 10 deletions frontend/public/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as _ from 'lodash-es';
import * as React from 'react';
import { Helmet } from 'react-helmet';
import { connect, Dispatch } from 'react-redux';
import { useTranslation } from 'react-i18next';
import {
Accordion,
AccordionContent,
Expand Down Expand Up @@ -86,7 +87,7 @@ const SearchPage_: React.FC<SearchProps & StateProps & DispatchProps> = (props)
const [labelFilterInput, setLabelFilterInput] = React.useState('');
const [typeaheadNameFilter, setTypeaheadNameFilter] = React.useState('');
const { namespace, noProjectsAvailable, pinnedResources } = props;

const { t } = useTranslation();
// Set state variables from the URL
React.useEffect(() => {
let kind: string, q: string, name: string;
Expand Down Expand Up @@ -208,9 +209,9 @@ const SearchPage_: React.FC<SearchProps & StateProps & DispatchProps> = (props)
return (
<>
<Helmet>
<title>Search</title>
<title>{t('search~Search')}</title>
</Helmet>
<PageHeading detail={true} title="Search">
<PageHeading detail={true} title={t('search~Search')}>
<Toolbar
id="search-toolbar"
clearAllFilters={clearAll}
Expand All @@ -230,7 +231,7 @@ const SearchPage_: React.FC<SearchProps & StateProps & DispatchProps> = (props)
),
}))}
deleteChip={updateNewItems}
categoryName="Resource"
categoryName={t('search~Resource')}
>
<ResourceListDropdown
selected={[...selectedItems]}
Expand All @@ -243,12 +244,12 @@ const SearchPage_: React.FC<SearchProps & StateProps & DispatchProps> = (props)
deleteChipGroup={clearLabelFilter}
chips={[...labelFilter]}
deleteChip={removeLabelFilter}
categoryName="Label"
categoryName={t('search~Label')}
>
<ToolbarFilter
chips={typeaheadNameFilter.length > 0 ? [typeaheadNameFilter] : []}
deleteChip={clearNameFilter}
categoryName="Name"
categoryName={t('search~Name')}
>
<SearchFilterDropdown
onChange={updateSearchFilter}
Expand Down Expand Up @@ -283,12 +284,12 @@ const SearchPage_: React.FC<SearchProps & StateProps & DispatchProps> = (props)
{pinnedResources.includes(resource) ? (
<>
<MinusCircleIcon className="co-search-group__pin-toggle__icon" />
Remove from navigation
{t('search~Remove from navigation')}
</>
) : (
<>
<PlusCircleIcon className="co-search-group__pin-toggle__icon" />
Add to navigation
{t('search~Add to navigation')}
</>
)}
</Button>
Expand All @@ -312,8 +313,8 @@ const SearchPage_: React.FC<SearchProps & StateProps & DispatchProps> = (props)
</Accordion>
{selectedItems.size === 0 && (
<MsgBox
title="No resources selected"
detail={<p>Select one or more resources from the dropdown.</p>}
title={t('search~No resources selected')}
detail={<p>{t('search~Select one or more resources from the dropdown.')}</p>}
/>
)}
</div>
Expand Down
12 changes: 11 additions & 1 deletion frontend/public/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ i18n
load: 'all',
debug: process.env.NODE_ENV === 'development',
detection: { caches: [] },
ns: ['public', 'masthead', 'nav', 'dashboard', 'badge', 'tour', 'quickstart', 'cloudshell'],
ns: [
'public',
'masthead',
'nav',
'dashboard',
'badge',
'tour',
'quickstart',
'cloudshell',
'search',
],
defaultNS: 'public',
nsSeparator: '~',
keySeparator: false,
Expand Down
10 changes: 10 additions & 0 deletions frontend/public/locales/en/search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Search": "Search",
"Resource": "Resource",
"Label": "Label",
"Name": "Name",
"Remove from navigation": "Remove from navigation",
"Add to navigation": "Add to navigation",
"No resources selected": "No resources selected",
"Select one or more resources from the dropdown.": "Select one or more resources from the dropdown."
}

0 comments on commit 249f578

Please sign in to comment.