make "I Understand" acknowledgement work for i18n case

This commit is contained in:
Jeremy Kauffman 2019-10-13 11:27:03 -04:00 committed by Sean Yesmunt
parent 255d9013b7
commit dfe23e47e4
3 changed files with 23 additions and 8 deletions

View file

@ -2,7 +2,6 @@
host = https://www.transifex.com host = https://www.transifex.com
[lbry-desktop.app-strings] [lbry-desktop.app-strings]
file_filter = static/locales/<lang>.json source_file = static/app-strings.json
source_file = static/locales/en.json
source_lang = en source_lang = en
type = KEYVALUEJSON type = KEYVALUEJSON

View file

@ -24,6 +24,8 @@ type State = {
rememberPassword: boolean, rememberPassword: boolean,
}; };
const acknowledgementText = __('I Understand');
class ModalWalletEncrypt extends React.PureComponent<Props, State> { class ModalWalletEncrypt extends React.PureComponent<Props, State> {
state = { state = {
newPassword: null, newPassword: null,
@ -63,8 +65,9 @@ class ModalWalletEncrypt extends React.PureComponent<Props, State> {
} }
onChangeUnderstandConfirm(event: SyntheticInputEvent<>) { onChangeUnderstandConfirm(event: SyntheticInputEvent<>) {
const regex = new RegExp('^.?' + acknowledgementText + '.?$', 'i');
this.setState({ this.setState({
understandConfirmed: /^.?i understand.?$/i.test(event.target.value), understandConfirmed: regex.test(event.target.value),
}); });
} }
@ -151,9 +154,13 @@ class ModalWalletEncrypt extends React.PureComponent<Props, State> {
</div> </div>
<FormField <FormField
inputButton={<Submit label={failMessage ? __('Encrypting Wallet') : __('Encrypt Wallet')} />} inputButton={<Submit label={failMessage ? __('Encrypting Wallet') : __('Encrypt Wallet')} />}
error={understandError === true ? 'You must enter "I understand"' : false} error={
label={__('Enter "I understand"')} understandError === true
placeholder={__('Dear computer, I understand')} ? __('You must enter "%acknowledgement_text%"', { acknowledgement_text: acknowledgementText })
: false
}
label={__('Enter "%acknowledgement_text%"', { acknowledgement_text: acknowledgementText })}
placeholder={__('Type "%acknowledgement_text%"', { acknowledgement_text: acknowledgementText })}
type="text" type="text"
name="wallet-understand" name="wallet-understand"
onChange={event => this.onChangeUnderstandConfirm(event)} onChange={event => this.onChangeUnderstandConfirm(event)}

View file

@ -791,5 +791,14 @@
"channel": "channel", "channel": "channel",
"Create": "Create", "Create": "Create",
"You have no rewards available.": "You have no rewards available.", "You have no rewards available.": "You have no rewards available.",
"URL does not include name.": "URL does not include name." "URL does not include name.": "URL does not include name.",
} "Enter a LBRY URL or search for videos, music, games and more": "Enter a LBRY URL or search for videos, music, games and more",
"I Understand": "I Understand",
"Enter \"%acknowledgement_text\"": "Enter \"%acknowledgement_text\"",
"Dear computer, %acknowledgement_text%": "Dear computer, %acknowledgement_text%",
"Enter \"%acknowledgement_text%\"": "Enter \"%acknowledgement_text%\"",
"Type \"%acknowledgement_text%\"": "Type \"%acknowledgement_text%\"",
"You must enter \"%acknowledgement_text%\"": "You must enter \"%acknowledgement_text%\"",
"Decrypt Wallet": "Decrypt Wallet",
"Your wallet has been encrypted with a local password, performing this action will remove this password.": "Your wallet has been encrypted with a local password, performing this action will remove this password."
}