-
Notifications
You must be signed in to change notification settings - Fork 6
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
Added ignore_script
and tested it.
#17
Conversation
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.
@mtr-d3v Thank you for the contribution! I had to close and reopen the PR because I failed to find another way to execute the Actions. I have left some comments, which is just one typo and two smaller issues regarding the style, which is open for discussion. Let me know if you are still interested in working on this, if not I'd be ready to take over.
langcodes/__init__.py
Outdated
if ignore_script: | ||
desired_triple = ( | ||
desired_complete.language, | ||
None, | ||
desired_complete.territory, | ||
) | ||
else: | ||
desired_triple = ( | ||
desired_complete.language, | ||
desired_complete.script, | ||
desired_complete.territory, | ||
) |
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'd prefer the following:
if ignore_script: | |
desired_triple = ( | |
desired_complete.language, | |
None, | |
desired_complete.territory, | |
) | |
else: | |
desired_triple = ( | |
desired_complete.language, | |
desired_complete.script, | |
desired_complete.territory, | |
) | |
desired_triple = ( | |
desired_complete.language, | |
None if ignore_script else desired_complete.script, | |
desired_complete.territory, | |
) |
langcodes/__init__.py
Outdated
if ( | ||
supported.language is None | ||
and supported.script is None | ||
and supported.territory is None | ||
): | ||
supported_triple = ('und', 'Zzzz', 'ZZ') | ||
supported_triple = ('und', 'Zzzz', 'ZZ') |
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 think thats a mistake, can you removed the added whitespaces?
langcodes/__init__.py
Outdated
if ignore_script: | ||
supported_triple = ( | ||
supported_complete.language, | ||
None, | ||
supported_complete.territory, | ||
) | ||
else: | ||
supported_triple = ( | ||
supported_complete.language, | ||
supported_complete.script, | ||
supported_complete.territory, | ||
) |
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.
This can be simplified as shown above.
langcodes/__init__.py
Outdated
@@ -1791,14 +1807,20 @@ def tag_distance(desired: Union[str, Language], supported: Union[str, Language]) | |||
|
|||
>>> tag_distance('ja', 'ja-Latn-US-hepburn') | |||
54 | |||
|
|||
If `ignore_script` is used, the script difference is ignored and a smaller | |||
differenge with lower score will be found. |
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.
Typo:
differenge with lower score will be found. | |
difference with lower score will be found. |
92171c9
to
9856e6a
Compare
9856e6a
to
c81a58a
Compare
0192a26
to
2fea5c3
Compare
@mtrd3v Again, thank you for the contribution! I rebased your branch and aligned the changes with my style preferences. This is going to be shipped with the next release! |
This PR fixes issue rspeer#59 by adding
ignore_script
and tests them.