Skip to content

Commit

Permalink
Merge pull request #182 from ethereum/translation
Browse files Browse the repository at this point in the history
Internationalisation!
  • Loading branch information
CarlBeek authored May 5, 2021
2 parents 5068b92 + afad2b6 commit a678da8
Show file tree
Hide file tree
Showing 102 changed files with 2,124 additions and 173 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Introduction](#introduction)
- [Tutorial for users](#tutorial-for-users)
- [Build requirements](#build-requirements)
- [For Linux or MacOS users](#for-linux-or-macos-users)
- [File Permissions](#file-permissions)
- [Option 1. Download binary executable file](#option-1-download-binary-executable-file)
- [Step 1. Installation](#step-1-installation)
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json)
- [language Argument](#language-argument)
- [Commands](#commands)
- [`new-mnemonic` Arguments](#new-mnemonic-arguments)
- [`existing-mnemonic` Arguments](#existing-mnemonic-arguments)
Expand All @@ -19,13 +20,15 @@
- [Step 0. Python version checking](#step-0-python-version-checking)
- [Step 1. Installation](#step-1-installation-1)
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json-1)
- [Language Argument](#language-argument)
- [Commands](#commands-1)
- [Arguments](#arguments)
- [Successful message](#successful-message-1)
- [Option 3. Build `deposit-cli` with `virtualenv`](#option-3-build-deposit-cli-with-virtualenv)
- [Step 0. Python version checking](#step-0-python-version-checking-1)
- [Step 1. Installation](#step-1-installation-2)
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json-2)
- [Language Argument](#language-argument-1)
- [Commands](#commands-2)
- [Arguments](#arguments-1)
- [Option 4. Use Docker image](#option-4-use-docker-image)
Expand All @@ -37,18 +40,21 @@
- [Option 1. Download binary executable file](#option-1-download-binary-executable-file-1)
- [Step 1. Installation](#step-1-installation-3)
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json-4)
- [Language Argument](#language-argument-2)
- [Commands](#commands-3)
- [Arguments](#arguments-3)
- [Option 2. Build `deposit-cli` with native Python](#option-2-build-deposit-cli-with-native-python-1)
- [Step 0. Python version checking](#step-0-python-version-checking-2)
- [Step 1. Installation](#step-1-installation-4)
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json-5)
- [Language Argument](#language-argument-3)
- [Commands](#commands-4)
- [Arguments](#arguments-4)
- [Option 3. Build `deposit-cli` with `virtualenv`](#option-3-build-deposit-cli-with-virtualenv-1)
- [Step 0. Python version checking](#step-0-python-version-checking-3)
- [Step 1. Installation](#step-1-installation-5)
- [Step 2. Create keys and `deposit_data-*.json`](#step-2-create-keys-and-deposit_data-json-6)
- [Language Argument](#language-argument-4)
- [Commands](#commands-5)
- [Arguments](#arguments-5)
- [Development](#development)
Expand Down Expand Up @@ -102,6 +108,14 @@ or run the following command to enter the interactive CLI and generate keys from
./deposit existing-mnemonic
```

###### language Argument

The Launchpad offers many language/internationalization options. If you wish to select one as a CLI argument, it must be passed in before one of the commands is chosen.

| Argument | Type | Description |
| -------- | -------- | -------- |
| `--language` | String. Options: `العربية`, `ελληνικά`, `English`, `Français`, `Bahasa melayu`, `Italiano`, `日本語`, `한국어`, `Português do Brasil`, `român`, `简体中文`. Default to `English` | The language you wish to use the CLI in. |

###### Commands

The CLI offers different commands depending on what you want to do with the tool.
Expand All @@ -118,7 +132,7 @@ You can use `new-mnemonic --help` to see all arguments. Note that if there are m
| Argument | Type | Description |
| -------- | -------- | -------- |
| `--num_validators` | Non-negative integer | The number of signing keys you want to generate. Note that the child key(s) are generated via the same master key. |
| `--mnemonic_language` | String. Options: `chinese_simplified`, `chinese_traditional`, `czech`, `english`, `italian`, `korean`, `portuguese`, `spanish`. Default to `english` | The mnemonic language |
| `--mnemonic_language` | String. Options: `简体中文`, `繁體中文`, `český jazyk`, `English`, `Italiano`, `한국어`, `Português`, `Español`. Default to `English` | The mnemonic language |
| `--folder` | String. Pointing to `./validator_keys` by default | The folder path for the keystore(s) and deposit(s) |
| `--chain` | String. `mainnet` by default | The chain setting for the signing domain. |
| `--eth1_withdrawal_address` | String. Eth1 address in hexadecimal encoded form | If this field is set and valid, the given Eth1 address will be used to create the withdrawal credentials. Otherwise, it will generate withdrawal credentials with the mnemonic-derived withdrawal public key in [EIP-2334 format](https://eips.ethereum.org/EIPS/eip-2334#eth2-specific-parameters). |
Expand Down Expand Up @@ -199,6 +213,9 @@ You can also run the tool with optional arguments:
./deposit.sh existing-mnemonic --num_validators=<NUM_VALIDATORS> --validator_start_index=<START_INDEX> --chain=<CHAIN_NAME> --folder=<YOUR_FOLDER_PATH>
```

###### Language Argument

See [here](#language_argument) for `--language` arguments.
###### Commands

See [here](#commands)
Expand Down Expand Up @@ -262,6 +279,10 @@ python3 ./eth2deposit/deposit.py new-mnemonic --num_validators=<NUM_VALIDATORS>
python3 ./eth2deposit/deposit.py existing-mnemonic --num_validators=<NUM_VALIDATORS> --validator_start_index=<START_INDEX> --chain=<CHAIN_NAME> --folder=<YOUR_FOLDER_PATH>
```

###### Language Argument

See [here](#language_argument) for `--language` arguments.

###### Commands

See [here](#commands)
Expand Down Expand Up @@ -341,6 +362,10 @@ deposit.exe new-mnemonic --num_validators=<NUM_VALIDATORS> --mnemonic_language=e
deposit.exe existing-mnemonic --num_validators=<NUM_VALIDATORS> --validator_start_index=<START_INDEX> --chain=<CHAIN_NAME> --folder=<YOUR_FOLDER_PATH>
```

###### Language Argument

See [here](#language_argument) for `--language` arguments.

###### Commands

See [here](#commands)
Expand Down Expand Up @@ -399,6 +424,10 @@ You can also run the tool with optional arguments:
./deposit.sh existing-mnemonic --num_validators=<NUM_VALIDATORS> --validator_start_index=<START_INDEX> --chain=<CHAIN_NAME> --folder=<YOUR_FOLDER_PATH>
```

###### Language Argument

See [here](#language_argument) for `--language` arguments.

###### Commands

See [here](#commands)
Expand Down Expand Up @@ -459,6 +488,10 @@ python .\eth2deposit\deposit.py new-mnemonic --num_validators=<NUM_VALIDATORS> -
python .\eth2deposit\deposit.pyexisting-mnemonic --num_validators=<NUM_VALIDATORS> --validator_start_index=<START_INDEX> --chain=<CHAIN_NAME> --folder=<YOUR_FOLDER_PATH>
```

###### Language Argument

See [here](#language_argument) for `--language` arguments.

###### Commands

See [here](#commands)
Expand Down
7 changes: 5 additions & 2 deletions build_configs/linux/build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ block_cipher = None

a = Analysis(['../../eth2deposit/deposit.py'],
binaries=[],
datas=[('../../eth2deposit/key_handling/key_derivation/word_lists/*.txt', './eth2deposit/key_handling/key_derivation/word_lists/')],
datas=[
('../../eth2deposit/key_handling/key_derivation/word_lists/*.txt', './eth2deposit/key_handling/key_derivation/word_lists/'),
('../../eth2deposit/intl', './eth2deposit/intl',)
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
excludes=['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
Expand Down
17 changes: 15 additions & 2 deletions build_configs/linux/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-r ../../requirements.txt

# Build tools for binary distribution
PyInstaller==3.6 \
--hash=sha256:3730fa80d088f8bb7084d32480eb87cbb4ddb64123363763cf8f2a1378c1c4b7
pyinstaller==4.2 \
--hash=sha256:f5c0eeb2aa663cce9a5404292c0195011fa500a6501c873a466b2e8cad3c950c
setuptools==49.2.0 \
--hash=sha256:272c7f48f5cddc5af5901f4265274c421c7eede5c8bc454ac2903d3f8fc365e9 \
--hash=sha256:afe9e81fee0270d3f60d52608549cc8ec4c46dada8c95640c1a00160f577acf2
Expand Down Expand Up @@ -45,3 +45,16 @@ altgraph==0.17 \
macholib==1.14 \
--hash=sha256:0c436bc847e7b1d9bda0560351bf76d7caf930fb585a828d13608839ef42c432 \
--hash=sha256:c500f02867515e6c60a27875b408920d18332ddf96b4035ef03beddd782d4281
pyinstaller-hooks-contrib==2021.1 \
--hash=sha256:27558072021857d89524c42136feaa2ffe4f003f1bdf0278f9b24f6902c1759c \
--hash=sha256:892310e6363655838485ee748bf1c5e5cade7963686d9af8650ee218a3e0b031
importlib-metadata==3.10.0 \
--hash=sha256:c9db46394197244adf2f0b08ec5bc3cf16757e9590b02af1fca085c16c0d600a \
--hash=sha256:d2d46ef77ffc85cbf7dac7e81dd663fde71c45326131bea8033b9bad42268ebe
zipp==3.4.1 \
--hash=sha256:3607921face881ba3e026887d8150cca609d517579abe052ac81fc5aeffdbd76 \
--hash=sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea5a63edc3e03098
typing-extensions==3.7.4.3 \
--hash=sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918 \
--hash=sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c \
--hash=sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f
9 changes: 6 additions & 3 deletions build_configs/macos/build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ block_cipher = None


a = Analysis(['../../eth2deposit/deposit.py'],
binaries=[('/System/Library/Frameworks/Tk.framework/Tk', 'tk'), ('/System/Library/Frameworks/Tcl.framework/Tcl', 'tcl')],
datas=[('../../eth2deposit/key_handling/key_derivation/word_lists/*.txt', './eth2deposit/key_handling/key_derivation/word_lists/')],
binaries=None,
datas=[
('../../eth2deposit/key_handling/key_derivation/word_lists/*.txt', './eth2deposit/key_handling/key_derivation/word_lists/'),
('../../eth2deposit/intl', './eth2deposit/intl',)
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
excludes=['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
Expand Down
17 changes: 15 additions & 2 deletions build_configs/macos/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-r ../../requirements.txt

# Build tools for binary distribution
PyInstaller==3.6 \
--hash=sha256:3730fa80d088f8bb7084d32480eb87cbb4ddb64123363763cf8f2a1378c1c4b7
pyinstaller==4.2 \
--hash=sha256:f5c0eeb2aa663cce9a5404292c0195011fa500a6501c873a466b2e8cad3c950c
setuptools==49.2.0 \
--hash=sha256:272c7f48f5cddc5af5901f4265274c421c7eede5c8bc454ac2903d3f8fc365e9 \
--hash=sha256:afe9e81fee0270d3f60d52608549cc8ec4c46dada8c95640c1a00160f577acf2
Expand Down Expand Up @@ -45,3 +45,16 @@ altgraph==0.17 \
macholib==1.14 \
--hash=sha256:0c436bc847e7b1d9bda0560351bf76d7caf930fb585a828d13608839ef42c432 \
--hash=sha256:c500f02867515e6c60a27875b408920d18332ddf96b4035ef03beddd782d4281
pyinstaller-hooks-contrib==2021.1 \
--hash=sha256:27558072021857d89524c42136feaa2ffe4f003f1bdf0278f9b24f6902c1759c \
--hash=sha256:892310e6363655838485ee748bf1c5e5cade7963686d9af8650ee218a3e0b031
importlib-metadata==3.10.0 \
--hash=sha256:c9db46394197244adf2f0b08ec5bc3cf16757e9590b02af1fca085c16c0d600a \
--hash=sha256:d2d46ef77ffc85cbf7dac7e81dd663fde71c45326131bea8033b9bad42268ebe
zipp==3.4.1 \
--hash=sha256:3607921face881ba3e026887d8150cca609d517579abe052ac81fc5aeffdbd76 \
--hash=sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea5a63edc3e03098
typing-extensions==3.7.4.3 \
--hash=sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918 \
--hash=sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c \
--hash=sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f
7 changes: 5 additions & 2 deletions build_configs/windows/build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ block_cipher = None

a = Analysis(['..\\..\\eth2deposit\\deposit.py'],
binaries=[],
datas=[('..\\..\\eth2deposit\\key_handling\\key_derivation\\word_lists\\*.txt', '.\\eth2deposit\\key_handling\\key_derivation\\word_lists')],
datas=[
('..\\..\\eth2deposit\\key_handling\\key_derivation\\word_lists\\*.txt', '.\\eth2deposit\\key_handling\\key_derivation\\word_lists'),
('..\\..\\eth2deposit\\intl', '.\\eth2deposit\\intl'),
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
excludes=['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
Expand Down
17 changes: 15 additions & 2 deletions build_configs/windows/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-r ../../requirements.txt

# Build tools for binary distribution
PyInstaller==3.6 \
--hash=sha256:3730fa80d088f8bb7084d32480eb87cbb4ddb64123363763cf8f2a1378c1c4b7
pyinstaller==4.2 \
--hash=sha256:f5c0eeb2aa663cce9a5404292c0195011fa500a6501c873a466b2e8cad3c950c
setuptools==49.2.0 \
--hash=sha256:272c7f48f5cddc5af5901f4265274c421c7eede5c8bc454ac2903d3f8fc365e9 \
--hash=sha256:afe9e81fee0270d3f60d52608549cc8ec4c46dada8c95640c1a00160f577acf2
Expand Down Expand Up @@ -65,3 +65,16 @@ pywin32==228 \
pywin32-ctypes==0.2.0 \
--hash=sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98 \
--hash=sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942
pyinstaller-hooks-contrib==2021.1 \
--hash=sha256:27558072021857d89524c42136feaa2ffe4f003f1bdf0278f9b24f6902c1759c \
--hash=sha256:892310e6363655838485ee748bf1c5e5cade7963686d9af8650ee218a3e0b031
importlib-metadata==3.10.0 \
--hash=sha256:c9db46394197244adf2f0b08ec5bc3cf16757e9590b02af1fca085c16c0d600a \
--hash=sha256:d2d46ef77ffc85cbf7dac7e81dd663fde71c45326131bea8033b9bad42268ebe
zipp==3.4.1 \
--hash=sha256:3607921face881ba3e026887d8150cca609d517579abe052ac81fc5aeffdbd76 \
--hash=sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea5a63edc3e03098
typing-extensions==3.7.4.3 \
--hash=sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918 \
--hash=sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c \
--hash=sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f
70 changes: 36 additions & 34 deletions eth2deposit/cli/existing_mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,63 @@
from eth2deposit.utils.constants import (
WORD_LISTS_PATH,
)
from eth2deposit.utils.click import (
captive_prompt_callback,
jit_option,
)
from eth2deposit.utils.intl import load_text
from eth2deposit.utils.validation import validate_int_range
from .generate_keys import (
generate_keys,
generate_keys_arguments_decorator,
)


def validate_mnemonic(cts: click.Context, param: Any, mnemonic: str) -> str:
def validate_mnemonic(ctx: click.Context, param: Any, mnemonic: str) -> str:
if verify_mnemonic(mnemonic, WORD_LISTS_PATH):
return mnemonic
else:
raise ValidationError('That is not a valid mnemonic, please check for typos.')
raise ValidationError(load_text(['err_invalid_mnemonic']))


@click.command(
help='Generate (or recover) keys from an existing mnemonic',
help=load_text(['arg_existing_mnemonic', 'help'], func='existing_mnemonic'),
)
@click.pass_context
@click.option(
'--mnemonic',
@jit_option(
callback=validate_mnemonic,
help=('The mnemonic that you used to generate your keys. (It is recommended not to use this argument, and wait for '
'the CLI to ask you for your mnemonic as otherwise it will appear in your shell history.)'),
prompt='Please enter your mnemonic separated by spaces (" ")',
required=True,
help=lambda: load_text(['arg_mnemonic', 'help'], func='existing_mnemonic'),
param_decls='--mnemonic',
prompt=lambda: load_text(['arg_mnemonic', 'prompt'], func='existing_mnemonic'),
type=str,
)
@click.password_option(
'--mnemonic-password',
@jit_option(
callback=captive_prompt_callback(
lambda x: x,
lambda: load_text(['arg_mnemonic_password', 'prompt'], func='existing_mnemonic'),
lambda: load_text(['arg_mnemonic_password', 'confirm'], func='existing_mnemonic'),
lambda: load_text(['arg_mnemonic_password', 'mismatch'], func='existing_mnemonic'),
True,
),
default='',
help=('This is almost certainly not the argument you are looking for: it is for mnemonic passwords, not keystore '
'passwords. Providing a password here when you didn\'t use one initially, can result in lost keys (and '
'therefore funds)! Also note that if you used this tool to generate your mnemonic intially, then you did not '
'use a mnemonic password. However, if you are certain you used a password to "increase" the security of your '
'mnemonic, this is where you enter it.'),
help=lambda: load_text(['arg_mnemonic_password', 'help'], func='existing_mnemonic'),
hidden=True,
param_decls='--mnemonic-password',
prompt=False,
)
@click.option(
'--validator_start_index',
confirmation_prompt=True,
@jit_option(
callback=captive_prompt_callback(
lambda num: validate_int_range(num, 0, 2**32),
lambda: load_text(['arg_validator_start_index', 'prompt'], func='existing_mnemonic'),
lambda: load_text(['arg_validator_start_index', 'confirm'], func='existing_mnemonic'),
),
default=0,
help=('Enter the index (key number) you wish to start generating more keys from. '
'For example, if you\'ve generated 4 keys in the past, you\'d enter 4 here,'),
prompt=('Enter the index (key number) you wish to start generating more keys from. '
'For example, if you\'ve generated 4 keys in the past, you\'d enter 4 here,'),
type=click.IntRange(0, 2**32 - 1),
help=lambda: load_text(['arg_validator_start_index', 'help'], func='existing_mnemonic'),
param_decls="--validator_start_index",
prompt=lambda: load_text(['arg_validator_start_index', 'prompt'], func='existing_mnemonic'),
)
@generate_keys_arguments_decorator
@click.pass_context
def existing_mnemonic(ctx: click.Context, mnemonic: str, mnemonic_password: str, **kwargs: Any) -> None:
if mnemonic_password != '':
click.clear()
click.confirm(
('Are you absolutely certain that you used a mnemonic password? '
'(This is different from a keystore password!) '
'Using one when you are not supposed to can result in loss of funds!'),
abort=True)

ctx.obj = {'mnemonic': mnemonic, 'mnemonic_password': mnemonic_password}
ctx.obj = {} if ctx.obj is None else ctx.obj # Create a new ctx.obj if it doesn't exist
ctx.obj.update({'mnemonic': mnemonic, 'mnemonic_password': mnemonic_password})
ctx.forward(generate_keys)
Loading

0 comments on commit a678da8

Please sign in to comment.