Skip to content

Commit

Permalink
feat: added localization for some labels (#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
ILya Volchenkov committed Jul 9, 2021
1 parent eba5512 commit ec50858
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/ApiInfo/ApiInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
InfoSpanBox,
InfoSpanBoxWrap,
} from './styled.elements';
import { l } from '../../services/Labels';

export interface ApiInfoProps {
store: AppStore;
Expand Down Expand Up @@ -79,14 +80,14 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
</ApiHeader>
{!hideDownloadButton && (
<p>
Download OpenAPI specification:
{l('downloadSpecification')}:
<DownloadButton
download={downloadFilename || true}
target="_blank"
href={downloadLink}
onClick={this.handleDownloadClick}
>
Download
{l('download')}
</DownloadButton>
</p>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/RequestSamples/RequestSamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SourceCodeWithCopy } from '../SourceCode/SourceCode';

import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements';
import { OptionsContext } from '../OptionsProvider';
import { l } from '../../services/Labels';

export interface RequestSamplesProps {
operation: OperationModel;
Expand All @@ -26,7 +27,7 @@ export class RequestSamples extends React.Component<RequestSamplesProps> {
return (
(hasSamples && (
<div>
<RightPanelHeader> Request samples </RightPanelHeader>
<RightPanelHeader> {l('requestSamples')} </RightPanelHeader>

<Tabs defaultIndex={0}>
<TabList hidden={hideTabList}>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ResponseSamples/ResponseSamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { OperationModel } from '../../services/models';

import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements';
import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
import { l } from '../../services/Labels';

export interface ResponseSamplesProps {
operation: OperationModel;
Expand All @@ -23,7 +24,7 @@ export class ResponseSamples extends React.Component<ResponseSamplesProps> {
return (
(responses.length > 0 && (
<div>
<RightPanelHeader> Response samples </RightPanelHeader>
<RightPanelHeader> {l('responseSamples')} </RightPanelHeader>

<Tabs defaultIndex={0}>
<TabList>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Responses/ResponsesList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { l } from '../../services/Labels';
import { ResponseModel } from '../../services/models';
import styled from '../../styled-components';
import { ResponseView } from './Response';
Expand Down Expand Up @@ -26,7 +27,7 @@ export class ResponsesList extends React.PureComponent<ResponseListProps> {

return (
<div>
<ResponsesHeader>{isCallback ? 'Callback responses' : 'Responses'}</ResponsesHeader>
<ResponsesHeader>{isCallback ? l('callbackResponses') : l('responses')}</ResponsesHeader>
{responses.map(response => {
return <ResponseView key={response.code} response={response} />;
})}
Expand Down
12 changes: 12 additions & 0 deletions src/services/Labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export interface LabelsConfig {
arrayOf: string;
webhook: string;
const: string;
download: string;
downloadSpecification: string;
responses: string;
callbackResponses: string;
requestSamples: string;
responseSamples: string;
}

export type LabelsConfigRaw = Partial<LabelsConfig>;
Expand All @@ -26,6 +32,12 @@ const labels: LabelsConfig = {
arrayOf: 'Array of ',
webhook: 'Event',
const: 'Value',
download: 'Download',
downloadSpecification: 'Download OpenAPI specification',
responses: 'Responses',
callbackResponses: 'Callback responses',
requestSamples: 'Request samples',
responseSamples: 'Response samples',
};

export function setRedocLabels(_labels?: LabelsConfigRaw) {
Expand Down

0 comments on commit ec50858

Please sign in to comment.