Skip to content

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions pls_cli/please.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,70 @@ def quotes(show: bool = True) -> None:
)


@app.command('language', rich_help_panel='Utils and Configs')
Copy link
Owner

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/

Copy link
Author

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 👨‍💻

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
Copy link
Author

Choose a reason for hiding this comment

The 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?

Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Owner

Choose a reason for hiding this comment

The 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:
https://github.com/Textualize/rich/blob/master/examples/downloader.py

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:
Expand Down Expand Up @@ -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',
Expand All @@ -503,6 +591,8 @@ def setup() -> None:
else:
settings['show_quotes'] = True

settings['language'] = 'en'

settings['tasks'] = []
Settings().write_settings(settings)

Expand Down
Loading