-
-
Notifications
You must be signed in to change notification settings - Fork 12
Feature choose language #22
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
base: main
Are you sure you want to change the base?
Changes from 12 commits
1fc7e30
d96ad39
160440b
aba6e1b
f176cc7
70f87fb
1fb9a52
63ade95
13036fd
61866e1
ba981e6
047120c
c2ac056
01d98c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,70 @@ def quotes(show: bool = True) -> None: | |
) | ||
|
||
|
||
@app.command('language', rich_help_panel='Utils and Configs') | ||
def language(lang: str) -> None: | ||
"""Choose language 🛩️""" | ||
settings = Settings().get_settings() | ||
list_language = Settings().get_list_language() | ||
if lang.lower() in list(list_language.keys()): | ||
if settings['language'] == lang: | ||
pass | ||
else: | ||
settings['language'] = lang | ||
Settings().write_settings(settings) | ||
# Here function Dowload quotes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @guedesfelipe i am reformat the code, the download part would go here, but i really don't have much idea how to query the current branch to be able to download the quotes, can you give me a hint? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! I will take a look at the code and help you with that as soon as possible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the delay, I was busy these days and I still haven't been able to make an example code, but I was thinking of doing the part of downloading the translated files like this: Or with Requests library... |
||
|
||
center_print( | ||
Rule( | ||
'Thanks for letting me know that!', | ||
style=insert_or_delete_line_style, | ||
), | ||
style=insert_or_delete_text_style, | ||
) | ||
else: | ||
center_print( | ||
Rule( | ||
'Wrong option!', | ||
style=insert_or_delete_line_style, | ||
), | ||
style=insert_or_delete_text_style, | ||
) | ||
code_markdown = Markdown( | ||
""" | ||
pls list-language | ||
""" | ||
) | ||
|
||
center_print( | ||
'If you want to list the language of quotes, please use:', | ||
style='red', | ||
) | ||
console.print(code_markdown) | ||
|
||
|
||
@app.command('list-language', rich_help_panel='Utils and Configs') | ||
def list_language() -> None: | ||
"""List language options 💬""" | ||
list_language = Settings().get_list_language() | ||
|
||
task_table = Table( | ||
header_style=table_header_style, | ||
style=table_header_style, | ||
box=box.SIMPLE_HEAVY, | ||
) | ||
|
||
task_table.add_column('language', justify='center') | ||
task_table.add_column('', justify='center') | ||
|
||
for command, language in list_language.items(): | ||
|
||
command = f'{command}' | ||
language = f'{language}' | ||
|
||
task_table.add_row(command, language) | ||
center_print(task_table) | ||
|
||
|
||
@app.command('tasks', short_help='Show all Tasks :open_book:') | ||
@app.command(short_help='[s]Show all Tasks :open_book:[/]', deprecated=True) | ||
def showtasks() -> None: | ||
|
@@ -481,6 +545,30 @@ def setup() -> None: | |
) | ||
console.print(code_markdown) | ||
|
||
code_markdown = Markdown( | ||
""" | ||
pls language <language> | ||
""" | ||
) | ||
|
||
center_print( | ||
'If you want to change the language of quotes, please use:', | ||
style='red', | ||
) | ||
console.print(code_markdown) | ||
|
||
code_markdown = Markdown( | ||
""" | ||
pls list-language | ||
""" | ||
) | ||
|
||
center_print( | ||
'If you want to list the language of quotes, please use:', | ||
style='red', | ||
) | ||
console.print(code_markdown) | ||
|
||
center_print( | ||
'To apply the changes restart the terminal or use this command:', | ||
style='red', | ||
|
@@ -503,6 +591,8 @@ def setup() -> None: | |
else: | ||
settings['show_quotes'] = True | ||
|
||
settings['language'] = 'en' | ||
|
||
settings['tasks'] = [] | ||
Settings().write_settings(settings) | ||
|
||
|
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.
Here I suggest to using enum, like this:
https://typer.tiangolo.com/tutorial/parameter-types/enum/
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.
That was a better solution, it's already updated 👨💻