--- a/src/pyams_i18n/negotiator.py Thu Oct 08 09:27:36 2015 +0200
+++ b/src/pyams_i18n/negotiator.py Mon Dec 07 12:00:41 2015 +0100
@@ -86,8 +86,13 @@
"""Negotiate language based on server, browser and user settings"""
negotiator = query_utility(INegotiator)
if negotiator is not None:
- return negotiator.get_language(request)
- return get_browser_language(request)
+ locale_name = negotiator.get_language(request)
+ else:
+ locale_name = get_browser_language(request)
+ if '-' in locale_name:
+ # remove 'sub-locale' to prevent Babel and Zope exceptions for unknown locales
+ locale_name = locale_name.split('-')[0]
+ return locale_name
def get_locale(request):