Exemple #1
0
 def test_non_existent(self):
     best = get_best_language('xy-YY, xy;q=0.8')
     eq_(False, best)
Exemple #2
0
 def test_not_worst_choice(self):
     """Try not to fall back to 'es' here."""
     best = get_best_language('en-gb, en;q=0.8, fr-fr;q=0.6, es;q=0.2')
     eq_('en-US', best)
Exemple #3
0
 def test_fr_FR(self):
     best = get_best_language('fr-FR, es;q=0.8')
     eq_('fr', best)
Exemple #4
0
 def test_english_only(self):
     """Any way you slice it, this should be 'en-US'."""
     best = get_best_language('en-US, en;q=0.5')
     eq_('en-US', best)
Exemple #5
0
 def test_en_GB(self):
     """Stick with English if you can."""
     best = get_best_language('en-gb, fr;q=0.8')
     eq_('en-US', best)
Exemple #6
0
 def test_exact_match_region(self):
     """Exact match of a locale with language and region subtags."""
     best = get_best_language('pt-BR, en-US;q=0.5')
     eq_('pt-BR', best)
Exemple #7
0
 def test_non_existent_fallback(self):
     """Respect user's preferences as much as possible."""
     best = get_best_language('qaz-ZZ, fr-FR;q=0.5')
     eq_('fr', best)
Exemple #8
0
 def test_second_choice(self):
     """Respect the user's preferences during the first pass."""
     best = get_best_language('fr-FR, de;q=0.5')
     eq_('de', best)
Exemple #9
0
 def test_prefix_fallback(self):
     """No matches during the first pass. Fall back to prefix."""
     best = get_best_language('fr-FR, de-DE;q=0.5')
     eq_('fr', best)
Exemple #10
0
 def test_script_alias(self):
     """Our traditional Chinese locale is 'zh-TW'."""
     best = get_best_language('zh-Hant, fr;q=0.5')
     eq_('zh-TW', best)
Exemple #11
0
 def test_non_existent(self):
     """If we don't have any matches, return false."""
     best = get_best_language('qaz-ZZ, qaz;q=0.5')
     eq_(False, best)
Exemple #12
0
 def test_prefix_alias(self):
     """A generic request for Portuguese should go to 'pt-PT'."""
     best = get_best_language('pt, fr;q=0.5')
     eq_('pt-PT', best)
Exemple #13
0
 def test_overspecific_alias(self):
     """Our Irish locale is 'ga-IE'."""
     best = get_best_language('ga, fr;q=0.5')
     eq_('ga-IE', best)
Exemple #14
0
 def test_english_alias(self):
     """Our canonical English locale is 'en-US'."""
     best = get_best_language('en, fr;q=0.5')
     eq_('en-US', best)
Exemple #15
0
 def test_prefix_matching(self):
     """en-US is a better match for en-gb, es;q=0.2 than es."""
     best = get_best_language('en-gb, es;q=0.2')
     eq_('en-US', best)
Exemple #16
0
 def test_english_fallback(self):
     """Fall back to our canonical English locale, 'en-US'."""
     best = get_best_language('en-GB, fr-FR;q=0.5')
     eq_('en-US', best)
Exemple #17
0
 def test_english_only(self):
     best = get_best_language('en-us, en;q=0.8')
     eq_('en-US', best)
Exemple #18
0
 def test_exact_match_language(self):
     """Exact match of a locale with only a language subtag."""
     best = get_best_language('fr, en-US;q=0.5')
     eq_('fr', best)