-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract text from CLI to enable internationalisation #182
Conversation
@CarlBeek nice! Just to confirm the file structure, to translate |
@wackerow I've tested out uploading nested JSON into Crowdin & can confirm that this format is supported 👍 File uploaded (you'll need to accept my manager invite in order to view): File translation: |
@CarlBeek This looks great! Thanks so much for tackling this. I took a look through the codebase to find what's remaining to refactor, and will list it here to track:
Happy to give a hand refactoring the remaining pages, just let me know 👍😀 |
@wackerow, Thanks for the list. I've tackled the remaining files in 5fceda2.
|
@CarlBeek Updated the list above, and looks like that testing bug was fixed? I think the only thing left is a language flag, and an initial prompt if this flag isn't provided (before selecting mnemonic language). Anything else I'm missing before this is ready? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got errors while executing the macOS binary:
➜ ./deposit --new-mnemonics
Traceback (most recent call last):
File "eth2deposit/deposit.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/usr/local/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
File "eth2deposit/cli/existing_mnemonic.py", line 28, in <module>
File "eth2deposit/utils/intl.py", line 40, in load_text
FileNotFoundError: [Errno 2] No such file or directory: 'eth2deposit/intl/en/cli/existing_mnemonic.json'
[51580] Failed to execute script deposit
I guess the build.spec
should include the new json files to datas
.
@@ -0,0 +1,35 @@ | |||
{ | |||
"validate_password": { | |||
"msg_password_prompt": "Type the password that secures your validator keystore(s)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forwarding on a comment by @samajammin on initial intl audit (#180) that I agree with... consider making this clearer that the user is about to create a new password, vs typing an existing password, eg:
Create a password that will secure your validator keystore(s)
"Type the password that secures" kinda implies there is already password currently securing it.
@@ -0,0 +1,14 @@ | |||
{ | |||
"from_mnemonic": { | |||
"msg_key_creation": "Creating your keys:\t\t" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for us to avoid including the tabs (\t
) in the JSON files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to ignore it in Crowdin but it'd be ideal to remove these to not confuse translators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look into extraction this from the json and having the tabs encoded in separate print statements. 👍
Co-authored-by: Hsiao-Wei Wang <[email protected]>
Arabic, Romanian, Portuguese (Brazilian), Indonesian, Greek, French, Chinese (simplified), Korean
@CarlBeek Hey Carl! Wanted to circle back to this and try to organize final steps. I think the only thing left before was:
The translations from Crowdin are starting to come in, and the Launchpad side of things is tee'd up for at least 8 of these languages, but one final step is to make sure the CLI commands shown on the website correctly match this repo. Trying to get an estimate on how much is left here. Should we just temporarily default the CLI commands shown on the Launchpad to English while we finalize things here? Added the languages that are translated so far to a branch off this one, and put it in PR #191. I also see the Prater testnet was just added... Can't think of how this would delay/change anything, just wanted to make sure. Almost there! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some issues during QA. It looks good to me once these issues are fixed.
Awesome work! 🎉
* cli-shell-debug-0: intl start_index confirmation
@hwwhww, I've changed quite a bit since you last looked. As far as I can see everything is working perfectly from a translation standpoint. Please can you take one, hopefully final, look 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description of the folder
argument + the translations have to be updated; otherwise, LGTM! 👍 👍
def validate_int_range(num: Any, low: int, high: int) -> int: | ||
''' | ||
Verifies that `num` is an `int` andlow <= num < high | ||
''' | ||
try: | ||
num_int = int(num) # Try cast to int | ||
assert num_int == float(num) # Check num is not float | ||
assert low <= num_int < high # Check num in range | ||
return num_int | ||
except (ValueError, AssertionError): | ||
raise ValidationError(load_text(['err_not_positive_integer'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear why it includes low
but excludes high
. What do you think about including the given upper bound and adjusting the argument:
def validate_int_range(num: Any, low: int, high: int) -> int: | |
''' | |
Verifies that `num` is an `int` andlow <= num < high | |
''' | |
try: | |
num_int = int(num) # Try cast to int | |
assert num_int == float(num) # Check num is not float | |
assert low <= num_int < high # Check num in range | |
return num_int | |
except (ValueError, AssertionError): | |
raise ValidationError(load_text(['err_not_positive_integer'])) | |
def validate_int_range(num: Any, lower_bound: int, upper_bound: int) -> int:: | |
''' | |
Verifies that `num` is an `int` and `lower_bound <= num <= upper_bound` | |
''' | |
try: | |
num_int = int(num) # Try cast to int | |
assert num_int == float(num) # Check num is not float | |
assert lower_bound <= num_int <= upper_bound # Check num in range | |
return num_int | |
except (ValueError, AssertionError): | |
raise ValidationError(load_text(['err_not_positive_integer'])) |
and call validate_int_range(num, 0, 2**32 - 1)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two reasons:
- It follows python's
range
/indexing convention (egx in range(0,8)
,list[0,8]
) validate_int_range(num, 0, 2**32)
is neater thanvalidate_int_range(num, 0, 2**32 - 1)
'--non_interactive', | ||
default=False, | ||
is_flag=True, | ||
help='Disables interactive prompts.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unimportant, just FYI it didn't show when I execute python eth2deposit/deposit.py --help
. I guess it's because deposit CLI mixes click.option
and custom jit_option
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because I purposefully hid this option, I intended only to use it for testing. (See L47 for hidden argument.)
Are you of the opinion that we should be opening this up to users? (It may be useful to those integrating this into other tools)
Thanks for your feedback, @hwwhww. I'll merge this now and we can open separate PRs to change |
Internationalisation!
In order to support internationalisation, the text needs to be removed from the CLI and broken out into separate content files (
.json
).This PR implements this via a function that determines the context in which it was called (from the call stack) and uses this information to determine the correct files to load in.