[Zope-Checkins] CVS: Zope3/lib/python/Zope/I18n - ITranslationService.py:1.1.2.1
Jim Fulton
jim@zope.com
Sat, 19 Jan 2002 13:07:20 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/I18n
In directory cvs.zope.org:/tmp/cvs-serv12801
Added Files:
Tag: Zope-3x-branch
ITranslationService.py
Log Message:
*** empty log message ***
=== Added File Zope3/lib/python/Zope/I18n/ITranslationService.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Revision information: $Id: ITranslationService.py,v 1.1.2.1 2002/01/19 18:07:19 jim Exp $
"""
from Interface import Interface
class ITranslationService(Interface):
"""Translation Service
This interface provides methods for translating text, including
text with interpolation.
When we refer to text here, we mean text that follows the standard
Zope 3 text representation (tbd).
Standard arguments:
destination_language_tag -- The language tag of the langauge
to translate to.
context -- An object that provides contextual information for
determining client language preferences. It must
implement or have an adapter that implements
IUserPreferedLanguages.
Note that one of destination_language or context must be
passed. Otherwise a TypeError will be raised.
Also note that languages tags are defined by RFC 1766.
domain -- The domain is used to specify which translation to use.
Different products will often use a specific domain naming
translations supplied with the product.
"""
def translateSequence(source_sequence, domain,
context=None,
destination_language_tag=None,
data=None):
"""Translate a source sequence that represents text with interpolation
The source sequence is a sequence of text and IVariable
object. The IVariable objects define interpolation names for
data to be interpolated during or after translation.
A data mapping may be passed with keys for the values to be
interpolated. Extra keys are ignored. If any interpolation
names defined in the message don't have a key in the data
dictionary, then IVariable objects will be included in the
output for those names.
A sequence is returned including translated text and IVariable
objects for any interpolated names not supplied in the data
mapping.
"""
def translate(source_text, domain,
context=None,
destination_language_tag=None):
"""Translate source text
Translated text is returned.
"""
class IVariable(Interface):
"""Objects that supply placeholders for interpolated data
"""
def getInterpolationName():
"""Return a string describing the data to be interpolated.
"""