Skip to content

Commit

Permalink
Merge c63de8f into 8aa6c86
Browse files Browse the repository at this point in the history
  • Loading branch information
sushain97 committed Jan 3, 2022
2 parents 8aa6c86 + c63de8f commit ebcd458
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apertium_apy/handlers/list_language_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get(self):
return

if 'Accept-Language' in self.request.headers:
locales = [locale.split(';')[0] for locale in self.request.headers['Accept-Language'].split(',')]
locales = [locale.split(';')[0].strip() for locale in self.request.headers['Accept-Language'].split(',')]

for locale in locales:
result = yield get_localized_languages(locale, self.lang_names)
Expand Down
1 change: 0 additions & 1 deletion apertium_apy/utils/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ async def translate_nul_flush(to_translate, pipeline, unsafe_deformat, unsafe_re
deformatted = bytes(to_translate, 'utf-8')

nonce = '[/NONCE:' + token_urlsafe(8) + ']'
logging.error(bytes(format_prefs(prefs), 'utf-8'))
await proc_in.stdin.write(bytes(format_prefs(prefs), 'utf-8'))
await proc_in.stdin.write(deformatted)
await proc_in.stdin.write(bytes('\0' + nonce + '\0', 'utf-8'))
Expand Down
3 changes: 1 addition & 2 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,11 @@ def test_no_locale_lang_names_list(self):
response = self.fetch_json('/listLanguageNames')
self.assertEqual(response['en'], 'English')

@unittest.skip('Failing for unknown reasons')
def test_accept_languages_header_lang_names_list(self):
response = self.fetch_json('/listLanguageNames', headers={
'Accept-Language': 'fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5',
})
self.assertEqual(response['en'], 'Anglais')
self.assertEqual(response['en'], 'anglais')


class TestIdentifyLangHandler(BaseTestCase):
Expand Down

0 comments on commit ebcd458

Please sign in to comment.