=== modified file 'Mailman/Cgi/admin.py' --- Mailman/Cgi/admin.py 2018-06-18 11:35:51 +0000 +++ Mailman/Cgi/admin.py 2018-06-21 07:37:55 +0000 @@ -44,6 +44,15 @@ from Mailman.Utils import sha_new from Mailman.CSRFcheck import csrf_check +if mm_cfg.ADMIN_OVERVIEW_LANGUAGE_NEGOTIATION: + try: + import httpheader + lang_negotiation = True + except ImportError: + lang_negotiation = False +else: + lang_negotiation = False + # Set up i18n _ = i18n._ i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) @@ -263,12 +272,29 @@ # the page. # # This page should be displayed in the server's default language, which - # should have already been set. + # should have already been set, or users preferred language, which + # will be determined in negotiation with users browser. + lang = mm_cfg.DEFAULT_SERVER_LANGUAGE + if lang_negotiation: + client_langs = os.environ.get('HTTP_ACCEPT_LANGUAGE') + if client_langs: + server_langs = ['-'.join(key.split('_')) + for key in mm_cfg.LC_DESCRIPTIONS.keys()] + try: + ltag = httpheader.acceptable_language( + client_langs, server_langs) + if ltag: + lang = '_'.join(str(ltag).split('-')) + except httpheader.ParseError, e: + syslog('error', + 'listinfo: parse error on Accept-language tag %s: %s', + server_langs, e) + i18n.set_language(lang) hostname = Utils.get_domain() legend = _('%(hostname)s mailing lists - Admin Links') # The html `document' doc = Document() - doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) + doc.set_language(lang) doc.SetTitle(legend) # The table that will hold everything table = Table(border=0, width="100%") === modified file 'Mailman/Cgi/listinfo.py' --- Mailman/Cgi/listinfo.py 2018-06-03 20:19:49 +0000 +++ Mailman/Cgi/listinfo.py 2018-06-21 07:37:55 +0000 @@ -32,6 +32,15 @@ from Mailman.htmlformat import * from Mailman.Logging.Syslog import syslog +if mm_cfg.LISTINFO_OVERVIEW_LANGUAGE_NEGOTIATION: + try: + import httpheader + lang_negotiation = True + except ImportError: + lang_negotiation = False +else: + lang_negotiation = False + # Set up i18n _ = i18n._ i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) @@ -81,10 +90,25 @@ def listinfo_overview(msg=''): # Present the general listinfo overview hostname = Utils.get_domain() - # Set up the document and assign it the correct language. The only one we - # know about at the moment is the server's default. + # Set up the document and assign it the correct language. + lang = mm_cfg.DEFAULT_SERVER_LANGUAGE + if lang_negotiation: + client_langs = os.environ.get('HTTP_ACCEPT_LANGUAGE') + if client_langs: + server_langs = ['-'.join(key.split('_')) + for key in mm_cfg.LC_DESCRIPTIONS.keys()] + try: + ltag = httpheader.acceptable_language( + client_langs, server_langs) + if ltag: + lang = '_'.join(str(ltag).split('-')) + except httpheader.ParseError, e: + syslog('error', + 'listinfo: parse error on Accept-language tag %s: %s', + server_langs, e) + i18n.set_language(lang) doc = Document() - doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) + doc.set_language(lang) legend = _("%(hostname)s Mailing Lists") doc.SetTitle(legend) === modified file 'Mailman/Defaults.py.in' (properties changed: +x to -x) --- Mailman/Defaults.py.in 2018-06-13 08:22:47 +0000 +++ Mailman/Defaults.py.in 2018-06-21 07:37:55 +0000 @@ -314,6 +314,18 @@ # than Subscribe? Set to Yes in mm_cfg.py to make the default be Invite. DEFAULT_SUBSCRIBE_OR_INVITE = No +# Shall the listinfo overview display the guidance message in language +# negociated with user's browser? Set this value to Yes to enable +# language negotiation on HTTP/1.1, with Accept-Language: header. +# Set this value to No to display it in DEFAULT_SERVER_LANGUAGE. +LISTINFO_OVERVIEW_LANGUAGE_NEGOTIATION = Yes + +# Shall the list admin overview display the guidance message in language +# negociated with user's browser? Set this value to Yes to enable +# language negotiation on HTTP/1.1, with Accept-Language: header. +# Set this value to No to display it in DEFAULT_SERVER_LANGUAGE. +ADMIN_OVERVIEW_LANGUAGE_NEGOTIATION = No + ##### === modified file 'configure' --- configure 2018-01-12 12:44:15 +0000 +++ configure 2018-06-20 15:05:01 +0000 @@ -2285,6 +2285,44 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $havednspython" >&5 $as_echo "$havednspython" >&6; } +# See if httpheader is installed.(this is optional) +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking httpheader" >&5 +$as_echo_n "checking httpheader... " >&6; } + +cat > conftest.py < or +***** or +***** " >&5 +$as_echo "$as_me: WARNING: + +***** httpheader not found. It is required for i18n +***** of listinfo overview feature. Get it from +***** or +***** or +***** " >&2;} +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $havehttpheader" >&5 +$as_echo "$havehttpheader" >&6; } + # Check the email package version. { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's email package" >&5 $as_echo_n "checking Python's email package... " >&6; } === modified file 'configure.in' --- configure.in 2018-01-12 12:44:15 +0000 +++ configure.in 2018-06-19 10:33:16 +0000 @@ -114,6 +114,35 @@ fi AC_MSG_RESULT($havednspython) +# See if httpheader is installed.(this is optional) +AC_MSG_CHECKING(httpheader) +changequote(,) +cat > conftest.py < or +***** or +***** ]) +fi +AC_MSG_RESULT($havehttpheader) + # Check the email package version. AC_MSG_CHECKING(Python's email package) changequote(,) === modified file 'src/common.c' --- src/common.c 2018-06-17 23:47:34 +0000 +++ src/common.c 2018-06-21 07:49:45 +0000 @@ -178,6 +178,7 @@ static char* keepenvars[] = { "CONTENT_TYPE=", "HOST=", + "HTTP_ACCEPT_LANGUAGE", "HTTP_COOKIE=", "HTTP_FORWARDED_FOR=", "HTTP_HOST=",