Back to index

plone3  3.1.7
Namespaces | Functions | Variables
PlacelessTranslationService Namespace Reference

Namespaces

namespace  Domain
namespace  GettextMessageCatalog
namespace  interfaces
namespace  lazycatalog
namespace  load
namespace  memoize
namespace  msgfmt
namespace  Negotiator
namespace  patches
namespace  PlacelessTranslationService
namespace  tests
namespace  utility
namespace  utils

Functions

def getTranslationService
def translate
def utranslate
def getLanguages
def getLanguageName
def isRTL
def make_translation_service
def initialize

Variables

tuple pts_globals = globals()
string cp_id = 'TranslationService'
 translation_service = None
dictionary misc_
tuple security = ModuleSecurityInfo('Products.PlacelessTranslationService')

Detailed Description

$Id: __init__.py 69676 2008-08-09 09:04:27Z hannosch $

Function Documentation

def PlacelessTranslationService.getLanguageName (   args,
  kwargs 
)
see PlaceslessTranslationService.PTSWrapper

Definition at line 85 of file __init__.py.

00085 
00086 def getLanguageName(*args, **kwargs):
00087     """see PlaceslessTranslationService.PTSWrapper
00088     """
00089     return getTranslationService().getLanguageName(*args, **kwargs)
00090 
00091 security.declareProtected(view, 'isRTL')
00092 @deprecate("The isRTL method of the PTS package is deprecated and will be "
00093            "removed in the next PTS release. Use the information found in the "
           "Zope3 locale instead.")

Here is the call graph for this function:

def PlacelessTranslationService.getLanguages (   args,
  kwargs 
)
see PlaceslessTranslationService.PlaceslessTranslationService

Definition at line 76 of file __init__.py.

00076 
00077 def getLanguages(*args, **kwargs):
00078     """see PlaceslessTranslationService.PlaceslessTranslationService
00079     """
00080     return getTranslationService().getLanguages(*args, **kwargs)
00081 
00082 security.declareProtected(view, 'getLanguageName')
00083 @deprecate("The getLanguageName method of the PTS package is deprecated and "
00084            "will be removed in the next PTS release. Use the getLanguageName "
           "method on the translation service instead.")

Here is the call graph for this function:

returns the PTS instance

Definition at line 49 of file __init__.py.

00049 
00050 def getTranslationService():
00051     """returns the PTS instance
00052     """
00053     return translation_service
00054 
00055 security.declareProtected(view, 'translate')
00056 @deprecate("The translate method of the PTS package is deprecated and will be "
00057            "removed in the next PTS release. Use the translate method of the "
           "global translation service instead.")

Here is the caller graph for this function:

Definition at line 112 of file __init__.py.

00112 
00113 def initialize(context):
00114     # hook into the Control Panel
00115     global translation_service
00116 
00117     # allow for disabling PTS entirely by setting an environment variable.
00118     if bool(os.getenv('DISABLE_PTS')):
00119         log('Disabled by environment variable "DISABLE_PTS".', logging.WARNING)
00120         return
00121 
00122     cp = context._ProductContext__app.Control_Panel # argh
00123     if cp_id in cp.objectIds():
00124         cp_ts = getattr(cp, cp_id)
00125         # use the ts in the acquisition context of the control panel
00126         # translation_service = translation_service.__of__(cp)
00127         translation_service = PTSWrapper(cp_ts)
00128     else:
00129         cp_ts = make_translation_service(cp)
00130 
00131     # don't touch - this is the last version that didn't have the
00132     # attribute (0.4)
00133     instance_version = getattr(cp_ts, '_instance_version', (0, 4, 0, 0))
00134     if instance_version[3] > 99:
00135         log('development mode: translation service recreated',
00136             detail = '(found %s.%s.%s.%s)\n' % instance_version)
00137         cp._delObject(cp_id)
00138         cp_ts = make_translation_service(cp)
00139 
00140     if instance_version < PlacelessTranslationService._class_version:
00141         log('outdated translation service found, recreating',
00142             detail = '(found %s.%s.%s.%s)\n' % instance_version)
00143         cp._delObject(cp_id)
00144         purgeMoFileCache()
00145         cp_ts = make_translation_service(cp)
00146 
00147     # sweep products
00148     products = [getattr(p, 'package_name', 'Products.' + p.id) for
00149                 p in cp.Products.objectValues() if
00150                 getattr(p, 'thisIsAnInstalledProduct', False)]
00151     # Sort the products by lower-cased package name to gurantee a stable
00152     # load order
00153     products.sort(key=lambda p: p.lower())
00154     log('products: %r' % products, logging.DEBUG)
00155     for prod in products:
00156         # prod is a package name, we fake a globals dict with it
00157         try:
00158             prod_path = package_home({'__name__' : prod})
00159             cp_ts._load_i18n_dir(os.path.join(prod_path, 'i18n'))
00160         except KeyError:
00161             log("You have a stale entry for '%s' in your ZMI Products section."
00162                 "You should consider removing it." % prod, logging.INFO)
00163             continue
00164 
00165     # sweep the i18n directory for local catalogs
00166     instance_i18n = os.path.join(Globals.INSTANCE_HOME, 'i18n')
00167     if os.path.isdir(instance_i18n):
00168         cp_ts._load_i18n_dir(instance_i18n)
00169 
00170     instance_locales = os.path.join(Globals.INSTANCE_HOME, 'locales')
00171     if os.path.isdir(instance_locales):
00172         cp_ts._load_locales_dir(instance_locales)
00173 
00174     # didn't found any catalogs
00175     if not cp_ts.objectIds():
00176         log('no translations found!', logging.DEBUG)
00177 
00178     # set ZPT's translation service
00179     # NOTE: since this registry is a global var we can't register the
00180     #       persistent service itself (zodb connection) therefore a
00181     #       wrapper is created around it
00182     setGlobalTranslationService(PTSWrapper(cp_ts))

Here is the call graph for this function:

def PlacelessTranslationService.isRTL (   context,
  domain 
)
Returns true for a rtl language and false for a ltr language

Definition at line 94 of file __init__.py.

00094 
00095 def isRTL(context, domain):
00096     """Returns true for a rtl language and false for a ltr language
00097     """
00098     return getTranslationService().isRTL(context, domain)

Here is the call graph for this function:

Control_Panel translation service

Definition at line 99 of file __init__.py.

00099 
00100 def make_translation_service(cp):
00101     """Control_Panel translation service
00102     """
00103     global translation_service
00104     translation_service = PlacelessTranslationService('default')
00105     translation_service.id = cp_id
00106     cp._setObject(cp_id, translation_service)
00107     # We need to get the service in the context of the control panel so its
00108     # physical path is correct.
00109     cp_ts = getattr(cp, cp_id)
00110     translation_service = PTSWrapper(cp_ts)
00111     return cp_ts

Here is the caller graph for this function:

def PlacelessTranslationService.translate (   args,
  kwargs 
)
see PlaceslessTranslationService.PlaceslessTranslationService

Definition at line 58 of file __init__.py.

00058 
00059 def translate(*args, **kwargs):
00060     """see PlaceslessTranslationService.PlaceslessTranslationService
00061     """
00062     return getTranslationService().translate(*args, **kwargs)
00063 
00064 security.declareProtected(view, 'utranslate')
00065 @deprecate("The utranslate method of the PTS package is deprecated and will be "
00066            "removed in the next PTS release. Use the translate method of the "
           "global translation service instead.")

Here is the call graph for this function:

def PlacelessTranslationService.utranslate (   args,
  kwargs 
)
see PlaceslessTranslationService.PlaceslessTranslationService

Definition at line 67 of file __init__.py.

00067 
00068 def utranslate(*args, **kwargs):
00069     """see PlaceslessTranslationService.PlaceslessTranslationService
00070     """
00071     return getTranslationService().translate(*args, **kwargs)
00072 
00073 security.declareProtected(view, 'getLanguages')
00074 @deprecate("The getLanguages method of the PTS package is deprecated and will "
00075            "be removed in the next PTS release. Use the getLanguages method on "
           "the translation service instead.")

Here is the call graph for this function:


Variable Documentation

string PlacelessTranslationService.cp_id = 'TranslationService'

Definition at line 31 of file __init__.py.

Initial value:
00001 {
00002     'PlacelessTranslationService.png':
00003     Globals.ImageFile('www/PlacelessTranslationService.png', globals()),
00004     'GettextMessageCatalog.png':
00005     Globals.ImageFile('www/GettextMessageCatalog.png', globals()),
00006     }

Definition at line 37 of file __init__.py.

Definition at line 12 of file __init__.py.

tuple PlacelessTranslationService.security = ModuleSecurityInfo('Products.PlacelessTranslationService')

Definition at line 45 of file __init__.py.

Definition at line 34 of file __init__.py.