langcodes icon indicating copy to clipboard operation
langcodes copied to clipboard

Don't lose region/territory when converting back from display name

Open CaptainDriftwood opened this issue 3 years ago • 0 comments

Given a language code of en-ca, the following currently happens:

code = "en-ca"
tag = langcodes.get(code)  # Language.make(language='en', territory='CA')
display_name = tag.display_name()  # 'English (Canada)'
tag = langcodes.find(display_name)  # <- .find does not capture the territory, yielding Language.make(language='en')

Is there any way .find could correctly get the territory from the display name?

CaptainDriftwood avatar Oct 22 '21 21:10 CaptainDriftwood