How to use the translations.translateRaw function in translations

To help you get started, we’ve selected a few translations examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MyCryptoHQ / MyCrypto / common / components / WalletDecrypt / WalletDecrypt.tsx View on Github external
return;
      }

      let timeout = 0;
      if (wallet.attemptUnlock) {
        try {
          const web3Available = await isWeb3NodeAvailable();
          if (web3Available) {
            // timeout is only the maximum wait time before secondary view is shown
            // send view will be shown immediately on web3 resolve
            timeout = 1500;
            wallet.unlock();
          }
        } catch (e) {
          // The permissions request for MetaMask was displayed, but permission was denied.
          showNotification('danger', translateRaw('METAMASK_PERMISSION_DENIED'));
        }
      }

      window.setTimeout(() => {
        if (this.exists) {
          this.setState({
            selectedWalletKey: walletType,
            value: wallet.initialParams
          });
        }
      }, timeout);
    };
github MyCryptoHQ / MyCrypto / common / v2 / features / AddAccount / AddAccount.tsx View on Github external
return;
      }

      let timeout = 0;
      if (wallet.attemptUnlock) {
        try {
          const web3Available = await isWeb3NodeAvailable();
          if (web3Available) {
            // timeout is only the maximum wait time before secondary view is shown
            // send view will be shown immediately on web3 resolve
            timeout = 1000;
            wallet.unlock();
          }
        } catch (e) {
          // The permissions request for MetaMask was displayed, but permission was denied.
          showNotification('danger', translateRaw('METAMASK_PERMISSION_DENIED'));
        }
      }

      window.setTimeout(() => {
        if (this.exists) {
          this.setState({
            selectedWalletKey: walletType,
            value: wallet.initialParams
          });
        }
      }, timeout);
    };
github MetaMask / eth-ledger-bridge-keyring / ledger-bridge.js View on Github external
ledgerErrToMessage (err) {
        const isU2FError = (err) => !!err && !!(err).metaData
        const isStringError = (err) => typeof err === 'string'
        const isErrorWithId = (err) => err.hasOwnProperty('id') && err.hasOwnProperty('message')

        // https://developers.yubico.com/U2F/Libraries/Client_error_codes.html
        if (isU2FError(err)) {
          // Timeout
          if (err.metaData.code === 5) {
            return translateRaw('LEDGER_TIMEOUT')
          }

          return err.metaData.type
        }

        if (isStringError(err)) {
          // Wrong app logged into
          if (err.includes('6804')) {
            return translateRaw('LEDGER_WRONG_APP')
          }
          // Ledger locked
          if (err.includes('6801')) {
            return translateRaw('LEDGER_LOCKED')
          }

          return err
github MyCryptoHQ / MyCrypto / common / components / AddressFieldFactory / AddressFieldDropdown.tsx View on Github external
const addresses = recentAddresses.reduce((prev: { [label: string]: string }, next: string) => {
      // Prevent duplication.
      if (addressesInBook[next]) {
        return prev;
      }
      prev[
        translateRaw('RECENT_ADDRESS_NUMBER', { $number: (++recentAddressCount).toString() })
      ] = next;

      return prev;
    }, {});
github MyCryptoHQ / MyCrypto / common / libs / wallet / deterministic / ledger.ts View on Github external
function ledgerErrToMessage(err: LedgerError) {
  // https://developers.yubico.com/U2F/Libraries/Client_error_codes.html
  if (isU2FError(err)) {
    // Timeout
    if (err.metaData.code === 5) {
      return translateRaw('LEDGER_TIMEOUT');
    }

    return err.metaData.type;
  }

  if (isStringError(err)) {
    // Wrong app logged into
    if (err.includes('6804')) {
      return translateRaw('LEDGER_WRONG_APP');
    }
    // Ledger locked
    if (err.includes('6801')) {
      return translateRaw('LEDGER_LOCKED');
    }

    return err;
github MyCryptoHQ / MyCrypto / common / libs / transaction.ts View on Github external
async function balanceCheck(
  node: INode,
  tx: ExtendedRawTransaction,
  token: Token | null | undefined,
  value: Wei,
  gasCost: Wei
) {
  // Ensure their balance exceeds the amount they're sending
  const { balance, ETHBalance } = await getBalance(node, tx, token);
  if (value.gt(balance)) {
    throw new Error(translateRaw('GETH_Balance'));
  }
  // ensure gas cost is not greaterThan current eth balance
  // TODO check that eth balance is not lesser than txAmount + gasCost
  if (gasCost.gt(ETHBalance)) {
    throw new Error(
      `gasCost: ${gasCost.toString()} greaterThan ETHBalance: ${ETHBalance.toString()}`
    );
  }
}
github MyCryptoHQ / MyCrypto / common / containers / Tabs / GenerateWallet / components / Keystore / EnterPassword.tsx View on Github external
private getFeedback() {
    let feedback: string = '';
    const validity = this.getPasswordValidity();

    if (validity !== 'valid') {
      const { password, passwordValidation } = this.state;

      if (password.length < MINIMUM_PASSWORD_LENGTH) {
        feedback = translateRaw('INPUT_PASSWORD_PLACEHOLDER', {
          $pass_length: MINIMUM_PASSWORD_LENGTH.toString()
        });
      } else if (passwordValidation && passwordValidation.feedback) {
        feedback = translateRaw('WEAK_PASSWORD') + ' ' + passwordValidation.feedback.warning;
      } else {
        feedback = translateRaw('INVALID_PASSWORD');
      }
    }

    return feedback;
  }
github MyCryptoHQ / MyCrypto / common / containers / Tabs / GenerateWallet / components / Keystore / EnterPassword.tsx View on Github external
private getFeedback() {
    let feedback: string = '';
    const validity = this.getPasswordValidity();

    if (validity !== 'valid') {
      const { password, passwordValidation } = this.state;

      if (password.length < MINIMUM_PASSWORD_LENGTH) {
        feedback = translateRaw('INPUT_PASSWORD_PLACEHOLDER', {
          $pass_length: MINIMUM_PASSWORD_LENGTH.toString()
        });
      } else if (passwordValidation && passwordValidation.feedback) {
        feedback = translateRaw('WEAK_PASSWORD') + ' ' + passwordValidation.feedback.warning;
      } else {
        feedback = translateRaw('INVALID_PASSWORD');
      }
    }

    return feedback;
  }
github MyCryptoHQ / MyCrypto / common / libs / validators.ts View on Github external
export function isValidAddressLabel(
  address: string,
  label: string,
  addresses: { [address: string]: string },
  labels: { [label: string]: string },
  chainId: number
) {
  const addressAlreadyExists = !!addresses[address.toLowerCase()];
  const labelAlreadyExists = !!labels[label];
  const result: { isValid: boolean; addressError?: string; labelError?: string } = {
    isValid: true
  };

  if (!isValidAddress(address, chainId)) {
    result.addressError = translateRaw('INVALID_ADDRESS');
  }

  if (addressAlreadyExists) {
    result.addressError = translateRaw('ADDRESS_ALREADY_EXISTS');
  }

  if (!isValidLabelLength(label)) {
    result.labelError = translateRaw('INVALID_LABEL_LENGTH');
  }

  if (!isLabelWithoutENS(label)) {
    result.labelError = translateRaw('LABEL_CANNOT_CONTAIN_ENS_SUFFIX');
  }

  if (labelAlreadyExists) {
    result.labelError = translateRaw('LABEL_ALREADY_EXISTS');
github MyCryptoHQ / MyCrypto / common / libs / validators.ts View on Github external
const addressAlreadyExists = !!addresses[address.toLowerCase()];
  const labelAlreadyExists = !!labels[label];
  const result: { isValid: boolean; addressError?: string; labelError?: string } = {
    isValid: true
  };

  if (!isValidAddress(address, chainId)) {
    result.addressError = translateRaw('INVALID_ADDRESS');
  }

  if (addressAlreadyExists) {
    result.addressError = translateRaw('ADDRESS_ALREADY_EXISTS');
  }

  if (!isValidLabelLength(label)) {
    result.labelError = translateRaw('INVALID_LABEL_LENGTH');
  }

  if (!isLabelWithoutENS(label)) {
    result.labelError = translateRaw('LABEL_CANNOT_CONTAIN_ENS_SUFFIX');
  }

  if (labelAlreadyExists) {
    result.labelError = translateRaw('LABEL_ALREADY_EXISTS');
  }

  if (result.addressError || result.labelError) {
    result.isValid = false;
  }

  return result;
}

translations

translations api for node.js, browsers and the command line

MIT
Latest version published 9 years ago

Package Health Score

36 / 100
Full package analysis

Popular translations functions