def test_match_direct(self): self.assertEqual( structs.LanguageTag.fromstr("fr-CH"), structs.lookup_language( self.languages, list( map(structs.LanguageRange.fromstr, ["en", "fr-ch", "de-de"])))) self.assertEqual( structs.LanguageTag.fromstr("it"), structs.lookup_language( self.languages, list(map(structs.LanguageRange.fromstr, [ "it", ]))))
def test_decay_skips_extension_prefixes_properly(self): self.assertEqual( structs.LanguageTag.fromstr("de-DE"), structs.lookup_language( list(map(structs.LanguageTag.fromstr, [ "de-DE", "de-x", ])), list(map(structs.LanguageRange.fromstr, [ "de-x-foobar", ]))))
def test_decay(self): self.assertEqual( structs.LanguageTag.fromstr("de-Latn-DE-1999"), structs.lookup_language( self.languages, list( map(structs.LanguageRange.fromstr, ["de-de", "en-GB", "en"])))) self.assertEqual( structs.LanguageTag.fromstr("fr-CH"), structs.lookup_language( self.languages, list( map(structs.LanguageRange.fromstr, [ "fr-FR", "de-DE", "fr", ]))))
def test_decay_skips_extension_prefixes_properly(self): self.assertEqual( structs.LanguageTag.fromstr("de-DE"), structs.lookup_language( list(map(structs.LanguageTag.fromstr, [ "de-DE", "de-x", ])), list(map(structs.LanguageRange.fromstr, [ "de-x-foobar", ])) ) )
def test_match_direct(self): self.assertEqual( structs.LanguageTag.fromstr("fr-CH"), structs.lookup_language( self.languages, list(map(structs.LanguageRange.fromstr, [ "en", "fr-ch", "de-de" ])) ) ) self.assertEqual( structs.LanguageTag.fromstr("it"), structs.lookup_language( self.languages, list(map(structs.LanguageRange.fromstr, [ "it", ])) ) )
def test_decay(self): self.assertEqual( structs.LanguageTag.fromstr("de-Latn-DE-1999"), structs.lookup_language( self.languages, list(map(structs.LanguageRange.fromstr, [ "de-de", "en-GB", "en" ])) ) ) self.assertEqual( structs.LanguageTag.fromstr("fr-CH"), structs.lookup_language( self.languages, list(map(structs.LanguageRange.fromstr, [ "fr-FR", "de-DE", "fr", ])) ) )