Skip to content

Commit 378c676

Browse files
committed
feat: use translate=no attribute in code sensitive renderings
Signed-off-by: Marques Johansson <[email protected]>
1 parent ce27184 commit 378c676

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

src/components/ApiInfo/ApiInfo.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
6767
)) ||
6868
null;
6969

70-
const version = (info.version && <span>({info.version})</span>) || null;
70+
const version = (info.version && <span translate="no">({info.version})</span>) || null;
7171

7272
return (
7373
<Section>
@@ -82,11 +82,12 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
8282
{downloadUrls?.map(({ title, url }) => {
8383
return (
8484
<DownloadButton
85-
download={downloadFileName || true}
86-
target="_blank"
87-
href={url}
88-
rel="noreferrer"
8985
key={url}
86+
href={url}
87+
download={downloadFileName}
88+
target="_blank"
89+
rel="noopener noreferrer"
90+
translate="no"
9091
>
9192
{title}
9293
</DownloadButton>

src/components/Endpoint/Endpoint.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
5050
{options => (
5151
<OperationEndpointWrap>
5252
<EndpointInfo onClick={this.toggle} $expanded={expanded} $inverted={inverted}>
53-
<HttpVerb type={operation.httpVerb} $compact={this.props.compact}>
53+
<HttpVerb type={operation.httpVerb} $compact={this.props.compact} translate="no">
5454
{operation.httpVerb}
5555
</HttpVerb>
56-
<ServerRelativeURL>{operation.path}</ServerRelativeURL>
56+
<ServerRelativeURL translate="no">{operation.path}</ServerRelativeURL>
5757
<ShelfIcon
5858
float={'right'}
5959
color={inverted ? 'black' : 'white'}
@@ -73,7 +73,7 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
7373
<Markdown source={server.description || ''} compact={true} />
7474
<SelectOnClick>
7575
<ServerUrl>
76-
<span>
76+
<span translate="no">
7777
{hideHostname || options.hideHostname
7878
? basePath === '/'
7979
? ''

src/components/Fields/Field.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ export class Field extends React.Component<FieldProps> {
8080
onKeyPress={this.handleKeyPress}
8181
aria-label={`expand ${name}`}
8282
>
83-
{!hidePropertiesPrefix &&
84-
fieldParentsName.map(
85-
name => name + '.\u200B', // zero-width space, a special character is used for correct line breaking
86-
)}
87-
<span className="property-name">{name}</span>
8883
<ShelfIcon direction={expanded ? 'down' : 'right'} />
8984
</button>
85+
{!hidePropertiesPrefix &&
86+
fieldParentsName.map(
87+
name => name + '.\u200B', // zero-width space, a special character is used for correct line breaking
88+
)}
89+
<span className="property-name" translate="no">{name}</span>
9090
{labels}
9191
</ClickablePropertyNameCell>
9292
) : (
@@ -96,7 +96,7 @@ export class Field extends React.Component<FieldProps> {
9696
fieldParentsName.map(
9797
name => name + '.\u200B', // zero-width space, a special character is used for correct line breaking
9898
)}
99-
<span className="property-name">{name}</span>
99+
<span className="property-name" translate="no">{name}</span>
100100
{labels}
101101
</PropertyNameCell>
102102
);

src/components/Fields/FieldConstraints.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class ConstraintsView extends React.PureComponent<ConstraintsViewProps> {
1414
<span>
1515
{' '}
1616
{this.props.constraints.map(constraint => (
17-
<ConstraintItem key={constraint}> {constraint} </ConstraintItem>
17+
<ConstraintItem key={constraint} translate="no"> {constraint} </ConstraintItem>
1818
))}
1919
</span>
2020
);

src/components/SecuritySchemes/SecuritySchemes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class SecurityDefs extends React.PureComponent<SecurityDefsProps> {
3131
<SecurityDetailsStyle>
3232
<SecurityRow>
3333
<b>Security Scheme Type: </b>
34-
<span>{AUTH_TYPES[scheme.type] || scheme.type}</span>
34+
<span translate="no">{AUTH_TYPES[scheme.type] || scheme.type}</span>
3535
</SecurityRow>
3636
<SecurityDetails scheme={scheme} />
3737
</SecurityDetailsStyle>

src/utils/jsonToHtml.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ function stringifyStringLiteral(str: string) {
2727
}
2828

2929
function decorateWithSpan(value, className) {
30-
return '<span class="' + className + '">' + htmlEncode(value) + '</span>';
30+
return '<span class="' + className + '" translate="no">' + htmlEncode(value) + '</span>';
3131
}
3232

3333
function punctuation(val) {
34-
return '<span class="token punctuation">' + val + '</span>';
34+
return '<span class="token punctuation" translate="no">' + val + '</span>';
3535
}
3636

3737
function valueToHTML(value, maxExpandLevel: number) {
@@ -106,7 +106,7 @@ function objectToHTML(json, maxExpandLevel: number) {
106106
const key = keys[i];
107107
hasContents = true;
108108
output += '<li><div class="hoverable ' + collapsed + '">';
109-
output += '<span class="property token string">"' + htmlEncode(key) + '"</span>: ';
109+
output += '<span class="property token string" translate="no">"' + htmlEncode(key) + '"</span>: ';
110110
output += valueToHTML(json[key], maxExpandLevel);
111111
if (i < length - 1) {
112112
output += punctuation(',');

0 commit comments

Comments
 (0)