summaryrefslogtreecommitdiff
path: root/src/mailman/interfaces/languages.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/interfaces/languages.py')
-rw-r--r--src/mailman/interfaces/languages.py72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/mailman/interfaces/languages.py b/src/mailman/interfaces/languages.py
index 272cf4372..a41a6e80e 100644
--- a/src/mailman/interfaces/languages.py
+++ b/src/mailman/interfaces/languages.py
@@ -30,60 +30,66 @@ from zope.interface import Interface, Attribute
+class ILanguage(Interface):
+ """The representation of a language."""
+
+ code = Attribute('The 2-character language code.')
+
+ charset = Attribute('The character set or encoding for this language.')
+
+ description = Attribute("The language's description.")
+
+
+
class ILanguageManager(Interface):
"""A language manager.
Current, disabling languages is not supported.
"""
- def add_language(code, description, charset, enable=True):
+ def add_language(code, charset, description):
"""Teach the language manager about a language.
:param code: The short two-character language code for the
language. If the language manager already knows about this code,
the old language binding is lost.
- :param description: The English description of the language,
- e.g. 'English' or 'French'.
+ :type code: string
:param charset: The character set that the language uses,
e.g. 'us-ascii', 'iso-8859-1', or 'utf-8'
- :param enable: Enable the language at the same time.
+ :type charset: string
+ :param description: The English description of the language,
+ e.g. 'English' or 'French'.
+ :type description: string
"""
- def enable_language(code):
- """Enable a language that the manager already knows about.
+ codes = Attribute('An iterator over all known codes.')
- :raises KeyError: when the manager does not know about the given
- language code.
- """
+ languages = Attribute('An iterator of all the languages.')
- def get_description(code):
- """Return the language description for the given code.
+ def __getitem__(code):
+ """Return the language associated with the language code.
- :param code: The two letter language code to look up.
- :returns: The English description of the language.
- :raises KeyError: when the code has not been added.
+ :param code: The 2-letter language code.
+ :type code: string
+ :return: The language instance.
+ :rtype: `ILanguage`
+ :raises KeyError: if code is not associated with a known language.
"""
- def get_charset(code):
- """Return the character set for the given code.
+ def get(code, default=None):
+ """Return the language associated with the language code.
- :param code: The two letter language code to look up.
- :returns: The character set of the language.
- :raises KeyError: when the code has not been added.
+ :param code: The 2-letter language code.
+ :type code: string
+ :param default: The value to return if the code is not known.
+ :type default: anything
+ :return: The language instance or `default`.
+ :rtype: `ILanguage` or `default`
"""
- known_codes = Attribute(
- """An iterator over all known codes.""")
-
- enabled_codes = Attribute(
- """An iterator over all enabled codes.""")
-
- enabled_names = Attribute(
- """An iterator over all enabled language names.""")
-
+ def __contains__(code):
+ """True if the language code is known.
-
-class ILanguage(Interface):
- """The representation of a language."""
-
- code = Attribute("""The 2-character language code.""")
+ :return: A flag indicating whether the language code is known or not.
+ :rtype: bool
+ """