tldr-pages / tldr-python-client

:snake: Python command-line client for tldr pages 📚
https://pypi.org/project/tldr/
MIT License
599 stars 95 forks source link

Add support for other languages #83

Closed lucasoshiro closed 4 years ago

lucasoshiro commented 4 years ago

Hi!

Although the https://github.com/tldr-pages/tldr repository has pages in other languages than English, the only way to read a page in another language was changing the page source with -s or --source.

This PR makes tldr detect the system language and use it to download the page in that language if it's available. Otherwise, it will download in English instead. It's also possible to provide the language with -l or --language.

lucasoshiro commented 4 years ago

ping @waldyrious ! Can you review this, please? Thanks!

ivanhercaz commented 4 years ago

This PR is very interesting. When I have a bit of time I could review it, but I can't promise it, @lucasoshiro.

lucasoshiro commented 4 years ago

@ivanhercaz ok, thanks!

zlatanvasovic commented 4 years ago

@lucasoshiro I wasn't active much when you proposed this, so it seems I missed this PR.

This has some merge conflicts with the recently merged PRs that changed the way page requests operate. Are you still interested in working on this, to check if those recent changes work along with your proposed change?

Thank you for the valuable contribution nevertheless.

lucasoshiro commented 4 years ago

@zdroid I rebased this PR with master and solved the conflitcts, I think it's ok now. Thanks for the review!

zlatanvasovic commented 4 years ago

What do you think about adding another TLDR_ configuration variable? Maybe TLDR_PAGES_LANGUAGE or just TLDR_LANGUAGE. It would replace the need to type -l <language> every time.

MasterOdin commented 4 years ago

The client specification already includes words on how to support language environment variables: https://github.com/tldr-pages/tldr/blob/master/CLIENT-SPECIFICATION.md#language.

zlatanvasovic commented 4 years ago

@MasterOdin I decided to merge #101 first because else we'd be making too many redundant changes. But we can move on to complete this one now.

I've resolved the merge conflicts. What's left is to fix the way update_cache() works, so that it doesn't store redundant languages.