summaryrefslogtreecommitdiff
path: root/Mailman/Gui/Language.py
blob: 00fff147007c496cf9334e593df67e7ca8c480fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (C) 2001,2002 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

"""MailList mixin class managing the language options.
"""

from Mailman import mm_cfg
from Mailman import Utils
from Mailman import i18n
from Mailman.Logging.Syslog import syslog
from Mailman.Gui.GUIBase import GUIBase

_ = i18n._



class Language(GUIBase):
    def GetConfigCategory(self):
        return 'language', _('Language options')

    def GetConfigInfo(self, mlist, category, subcat=None):
        if category <> 'language':
            return None
        # Set things up for the language choices
        langs = mlist.GetAvailableLanguages()
        langnames = [_(Utils.GetLanguageDescr(L)) for L in langs]
        try:
            langi = langs.index(mlist.preferred_language)
        except ValueError:
            # Someone must have deleted the list's preferred language.  Could
            # be other trouble lurking!
            langi = 0

        all = Utils.GetDirectories(mm_cfg.TEMPLATE_DIR)
        all.sort()
        checked = [L in langs for L in all]
        allnames = [_(Utils.GetLanguageDescr(L)) for L in all]

        return [
            _('Natural language (internationalization) options.'),

            ('preferred_language', mm_cfg.Select,
             (langs, langnames, langi),
             0,
             _('Default language for this list.'),
             _('''This is the default natural language for this mailing list.
             If <a href="?VARHELP=language/available_languages">more than one
             language</a> is supported then users will be able to select their
             own preferences for when they interact with the list.  All other
             interactions will be conducted in the default language.  This
             applies to both web-based and email-based messages, but not to
             email posted by list members.''')),

            ('available_languages', mm_cfg.Checkbox,
             (allnames, checked, 0, all), 0,
             _('Languages supported by this list.'),

             _('''These are all the natural languages supported by this list.
             Note that the
             <a href="?VARHELP=language/preferred_language">default
             language</a> must be included.''')),

            ]

    def _setValue(self, mlist, property, val, doc):
        # If we're changing the list's preferred language, change the I18N
        # context as well
        if property == 'preferred_language':
            i18n.set_language(val)
        GUIBase._setValue(self, mlist, property, val, doc)