-
-
Notifications
You must be signed in to change notification settings - Fork 102
Add filter for languages with ll_CC description #133
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
Changes from 1 commit
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 |
---|---|---|
|
@@ -30,10 +30,20 @@ | |
'https://tldr-pages.github.io/assets/tldr.zip' | ||
) | ||
|
||
DEFAULT_LANG = os.environ.get( | ||
'LANG', | ||
'C' | ||
).split('_')[0] | ||
|
||
def filter_languages(lang): | ||
if lang in ['pt_PT', 'pt_BR', 'zh_TW']: | ||
return lang | ||
elif lang == "pt": | ||
return "pt_PT" | ||
return lang.split('_')[0] | ||
|
||
|
||
DEFAULT_LANG = filter_languages( | ||
os.environ.get( | ||
'LANG', | ||
'C' | ||
).split('.')[0]) | ||
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. Does anyone know how to apply this filter with chain notation for a nicer syntax like 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. Let's move the 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, that makes sense. |
||
|
||
if DEFAULT_LANG == 'C' or DEFAULT_LANG == 'POSIX': | ||
DEFAULT_LANG = None | ||
|
@@ -162,9 +172,11 @@ def get_platform_list(): | |
def get_language_list(): | ||
languages = os.environ.get('LANGUAGE', '').split(':') | ||
languages = list(map( | ||
lambda x: x.split('_')[0], | ||
filter(lambda x: not (x == 'C' or x == 'POSIX' or x == ''), languages) | ||
)) | ||
filter_languages, | ||
map( | ||
lambda x: x.split('.')[0], | ||
filter(lambda x: not (x == 'C' or x == 'POSIX' or x == ''), languages) | ||
))) | ||
if DEFAULT_LANG is not None: | ||
if DEFAULT_LANG not in languages: | ||
languages.append(DEFAULT_LANG) | ||
|
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'm not a fan of this name as it feels like what you might think it does from the name (given a list of languages, filter it down) is not the same as what it actually does (given a language, rewrite it to appropriate form).
get_language_code(language)
orget_tldr_language_code(language)
maybe?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.
Ok, for me a filter is something which modifies or removes an input and outputs the result, but I see your point.