Skip to content

Commit

Permalink
Disable google translate on mnemonic
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Jan 4, 2022
1 parent a1a9922 commit 1ac5eac
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

- Disable Google Translate on mnemonic

## 1.0.0

Spotlight change:
Expand Down
18 changes: 18 additions & 0 deletions src/popup/component/NoTranslate/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'

/**
* Disable Google Translate on child element
* https://cloud.google.com/translate/troubleshooting
*
* Main usage is to display generated mnemonic without modifications, and
* without sending it to Google servers.
*
* @param { { children: React.ReactNode } } props
*/
export default function NoTranslate(props) {
return (
<span className="notranslate" translate="no">
{props.children}
</span>
)
}
50 changes: 29 additions & 21 deletions src/popup/pages/BackupMnemonics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { sendMsg } from "../../../utils/commonMsg";
import Button from "../../component/Button";
import CustomView from "../../component/CustomView";
import Toast from "../../component/Toast";
import NoTranslate from "../../component/NoTranslate";
import "./index.scss";
class BackupMnemonics extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -115,30 +116,37 @@ class BackupMnemonics extends React.Component {
}
};
renderSelectedMne = () => {
return (<div className="mne-container mne-select-container">
{this.state.selectList.map((item, index) => {
return (<p
key={index + ""}
onClick={() => this.onClickTopItem(item, index)}
className={"mne-item-common mne-item mne-item-clicked click-cursor"}>{index + 1 + ". " + item.name}</p>)
})}
</div>)
return (
<NoTranslate>
<div className="mne-container mne-select-container">
{this.state.selectList.map((item, index) => {
return (<p
key={index + ""}
onClick={() => this.onClickTopItem(item, index)}
className={"mne-item-common mne-item mne-item-clicked click-cursor"}>{index + 1 + ". " + item.name}</p>)
})}
</div>
</NoTranslate>
)
}
renderMneList = () => {
return (
<div className={"mne-container"}>
{this.state.list.map((item, index) => {
return (
<div
key={index + ""}
onClick={() => this.onClickBottomItem(item, index)}
className={cx({
"mne-item-select": item.selected,
})}
><p className={"mne-item-record mne-item-noSelect click-cursor"}>{item.name}</p></div>)
})
}
</div>)
<NoTranslate>
<div className={"mne-container"}>
{this.state.list.map((item, index) => {
return (
<div
key={index + ""}
onClick={() => this.onClickBottomItem(item, index)}
className={cx({
"mne-item-select": item.selected,
})}
><p className={"mne-item-record mne-item-noSelect click-cursor"}>{item.name}</p></div>)
})
}
</div>
</NoTranslate>
)
}
renderBottomBtn = () => {
return (
Expand Down
3 changes: 2 additions & 1 deletion src/popup/pages/RevealSeed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SEC_SHOW_MNEMONIC } from "../../../constant/walletType";
import { getLanguage } from "../../../i18n";
import { sendMsg } from "../../../utils/commonMsg";
import CustomView from "../../component/CustomView";
import NoTranslate from "../../component/NoTranslate";
import SecurityPwd from "../../component/SecurityPwd";
import Toast from "../../component/Toast";
import "./index.scss"
Expand Down Expand Up @@ -32,7 +33,7 @@ class RevealSeedPage extends React.Component {
}

renderInput = () => {
return(<p className={"reveal-text"}>{this.state.mnemonic}</p>)
return(<NoTranslate><p className={"reveal-text"}>{this.state.mnemonic}</p></NoTranslate>)
}

onClickCheck = (password) => {
Expand Down
13 changes: 8 additions & 5 deletions src/popup/pages/ShowMnemonic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getLanguage } from "../../../i18n";
import { sendMsg } from "../../../utils/commonMsg";
import Button from "../../component/Button";
import CustomView from "../../component/CustomView";
import NoTranslate from "../../component/NoTranslate";
import "./index.scss";
class ShowMnemonic extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -39,11 +40,13 @@ class ShowMnemonic extends React.Component {

showMne = () => {
return (
<div className={"mne-container"}>
{this.state.mnemonic.split(" ").map((item, index) => {
return <p key={index + ""} className="mne-item mne-item-common">{index + 1 + ". " + item}</p>;
})}
</div>
<NoTranslate>
<div className={"mne-container"}>
{this.state.mnemonic.split(" ").map((item, index) => {
return <p key={index + ""} className="mne-item mne-item-common">{index + 1 + ". " + item}</p>;
})}
</div>
</NoTranslate>
);
};
goToNext = () => {
Expand Down

0 comments on commit 1ac5eac

Please sign in to comment.