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 bc16d12 commit fe840da
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Little things:
- Creating new wallets now generates 24-word mnemonic.
- Popup is now wider.
- Buttons to confirm wallet resetting are now red and no longer swapped.
- Blocked Google Translate from translating displayed mnemonic.

## 1.0.0

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 mne-item-common 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 mne-item-common click-cursor"}>{index + 1 + ". " + item.name}</p>)
})}
</div>
</NoTranslate>
)
}
renderMneList = () => {
return (
<div className={"mne-container"}>
{this.state.list.map((item, index) => {
return (
<p
key={index + ""}
onClick={() => this.onClickBottomItem(item, index)}
className={cx("mne-item mne-item-record click-cursor", {
"mne-item-select": item.selected,
})}
>{item.name}</p>)
})
}
</div>)
<NoTranslate>
<div className={"mne-container"}>
{this.state.list.map((item, index) => {
return (
<p
key={index + ""}
onClick={() => this.onClickBottomItem(item, index)}
className={cx("mne-item mne-item-record click-cursor", {
"mne-item-select": item.selected,
})}
>{item.name}</p>)
})
}
</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 fe840da

Please sign in to comment.