当前位置: 首页>>代码示例>>Python>>正文


Python translation.domain_functions函数代码示例

本文整理汇总了Python中trac.util.translation.domain_functions函数的典型用法代码示例。如果您正苦于以下问题:Python domain_functions函数的具体用法?Python domain_functions怎么用?Python domain_functions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了domain_functions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Copyright

# Created by Denis Yeldandi on 2011-02-21.
# Copyright (c) 2011 Denis Yeldandi. All rights reserved.
import itertools


from trac.core import *
from trac.web.api import ITemplateStreamFilter
from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script, add_script_data
from trac.config import Option, OrderedExtensionsOption
from genshi.builder import tag
from genshi.filters.transform import Transformer
from pkg_resources import resource_filename
from trac.util.translation import domain_functions
import pkg_resources 

_, tag_, N_, add_domain = domain_functions('Translate', ('_', 'tag_', 'N_', 'add_domain'))

class TranslateModule(Component):
    """A stream filter to add translate buttons."""

    implements(ITemplateStreamFilter, ITemplateProvider)
    googleApiKey = Option('translate', 'google_api_key', default='',
        doc='Google api key to use')


    def __init__(self):
        locale_dir = pkg_resources.resource_filename(__name__, 'locale')
        add_domain(self.env.path, locale_dir)

    # ITemplateStreamFilter methods
    def filter_stream(self, req, method, filename, stream, data):
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:web_ui.py

示例2: domain_functions

from trac.core import *
from genshi.filters import Transformer
from genshi.builder import tag
from genshi import HTML
from trac.web.api import IRequestFilter, ITemplateStreamFilter
from operator import attrgetter
from trac.util.translation import domain_functions
import pkg_resources
import re

# from trac.ticket.model import *

_, tag_, N_, add_domain = domain_functions("roadmapplugin", "_", "tag_", "N_", "add_domain")


# copied from RoadmapFilterPlugin.py, see https://trac-hacks.org/wiki/RoadmapFilterPlugin
def get_session_key(name):
    return "roadmap.filter.%s" % name


# copied from RoadmapFilterPlugin.py, see https://trac-hacks.org/wiki/RoadmapFilterPlugin
class FilterRoadmap(Component):
    """Filters roadmap milestones.

Mainly copied from [https://trac-hacks.org/wiki/RoadmapFilterPlugin RoadmapFilterPlugin]
and modified a bit.

Thanks to daveappendix """

    implements(IRequestFilter, ITemplateStreamFilter)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:roadmap.py

示例3: domain_functions

from trac.core import Component, implements
from trac.admin import IAdminPanelProvider
from trac.config import Configuration, Option, BoolOption, ListOption, \
                        FloatOption, ChoiceOption
from trac.env import IEnvironmentSetupParticipant
from trac.perm import PermissionSystem
from trac.util import arity
from trac.util.compat import md5, any
from trac.util.text import to_unicode, exception_to_unicode
from trac.util.translation import dgettext, domain_functions
from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script, \
                            add_script_data


_, N_, add_domain = domain_functions('tracworkflowadmin',
                                     '_', 'N_', 'add_domain')


if arity(Option.__init__) <= 5:
    def _option_with_tx(Base): # Trac 0.12.x
        class Option(Base):
            def __getattribute__(self, name):
                val = Base.__getattribute__(self, name)
                if name == '__doc__':
                    val = dgettext('tracworkflowadmin', val)
                return val
        return Option
else:
    def _option_with_tx(Base): # Trac 1.0 or later
        class Option(Base):
            def __init__(self, *args, **kwargs):
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:web_ui.py

示例4: domain_functions

# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#   The above copyright notice and this permission notice shall be included in
#   all copies or substantial portions of the Software. 
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------

from trac.util.translation import domain_functions


# i18n support
_, tag_, N_, add_domain = domain_functions('tracticketchangesetsplugin',
                                           '_', 'tag_', 'N_', 'add_domain')


def init_translation(envpath):
    #Bind the language catalogs to the locale directory
    import pkg_resources
    locale_dir = pkg_resources.resource_filename(__name__, 'locale')
    add_domain(envpath, locale_dir)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:translation.py

示例5: domain_functions

from genshi.builder import tag
from pkg_resources import resource_filename
from urllib import unquote_plus

from trac.core import Component, ExtensionPoint, Interface, implements
from trac.perm import IPermissionRequestor
from trac.resource import IResourceManager, Resource, ResourceNotFound, \
                          get_resource_name, get_resource_shortname, \
                          get_resource_url

# Import i18n methods.  Fallback modules maintain compatibility to Trac 0.11
# by keeping Babel optional here.
try:
    from trac.util.translation import domain_functions
    add_domain, _, ngettext, tag_ = \
        domain_functions('tracforms', ('add_domain', '_', 'ngettext', 'tag_'))
except ImportError:
    from genshi.builder import tag as tag_
    from trac.util.translation import gettext
    _ = gettext
    ngettext = _
    def add_domain(a,b,c=None):
        pass

from trac.web import IRequestHandler
from trac.web.api import HTTPBadRequest, HTTPUnauthorized

# Import AccountManagerPlugin methods, if plugin is installed.
try:
    from acct_mgr.api import IPasswordStore
    can_check_user = True
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:api.py

示例6: domain_functions

from trac.env import ISystemInfoProvider
from trac.perm import IPermissionGroupProvider

from acct_mgr.api import IPasswordStore

from gdata.apps.service import AppsService
from gdata.apps.groups.service import GroupsService
from gdata.service import BadAuthentication, CaptchaRequired
from gdata.apps.service import AppsForYourDomainException

from base64 import b64encode, b64decode

# i18n
from pkg_resources import resource_filename #@UnresolvedImport
from trac.util.translation import domain_functions
_, add_domain = domain_functions('googleappsauth', ('_', 'add_domain'))


class GoogleAppsPasswordStore(Component):
    """TracAccountManager Password Store which authenticates against a Google Apps domain"""

    implements(IPasswordStore, IPermissionGroupProvider, ISystemInfoProvider)

    # Plugin Options
    opt_key = 'google_apps'

    gapps_domain = Option(opt_key, 'domain', doc=_("Domain name of the Google Apps domain"))
    gapps_admin_username = Option(opt_key, 'admin_username', doc=_("Username or email with Google Apps admin access"))
    gapps_admin_secret = Option(opt_key, 'admin_secret', doc=_("Password for Google Apps admin account; this is magically encrypted to make storage slightly more secure"))
    gapps_group_access = Option(opt_key, 'group_access', doc=_("Optional Google Apps Group which is exclusively granted access to this Trac site"))
    #enable_multiple_stores = BoolOption(opt_key, 'enable_multiple_stores', False, """Optional flag to enable use of this plugin alongside other PasswordStore implementations (will slightly increase network overhead)""")
开发者ID:smeggingsmegger,项目名称:TracGoogleAppsAuthPlugin,代码行数:31,代码来源:plugin.py

示例7: OptionTx

                class OptionTx(Option):
                    def __getattribute__(self, name):
                        if name == '__class__':
                            return Option
                        value = Option.__getattribute__(self, name)
                        if name == '__doc__':
                            value = dgettext(doc_domain, value)
                        return value
                return OptionTx
        if len(options) == 1:
            return _option_with_tx(options[0], domain)
        else:
            return map(lambda option: _option_with_tx(option, domain), options)


    _, N_, gettext, ngettext, add_domain = domain_functions(
        'tracexceldownload', '_', 'N_', 'gettext', 'ngettext', 'add_domain')
    ChoiceOption = domain_options('tracexceldownload', ChoiceOption)


    class TranslationModule(Component):

        implements(IEnvironmentSetupParticipant)

        def __init__(self, *args, **kwargs):
            Component.__init__(self, *args, **kwargs)
            add_domain(self.env.path, resource_filename(__name__, 'locale'))

        # IEnvironmentSetupParticipant methods
        def environment_created(self):
            pass
开发者ID:t-kenji,项目名称:trac-exceldownload-plugin,代码行数:31,代码来源:translation.py

示例8: Copyright

# -*- coding: utf-8 -*-
# Copyright (C) 2010, 2012 Steffen Hoffmann <[email protected]>
#

from trac.core              import Component

# Import i18n methods.  Fallback modules maintain compatibility to Trac 0.11
# by keeping Babel optional here.
try:
    from  trac.util.translation  import  domain_functions
    add_domain, _, tag_ = \
        domain_functions('wikicalendar', ('add_domain', '_', 'tag_'))
except ImportError:
    from  genshi.builder         import  tag as tag_
    from  trac.util.translation  import  gettext
    _ = gettext
    def add_domain(a,b,c=None):
        pass


__all__ = ['WikiCalendarBuilder']


class WikiCalendarBuilder(Component):
    """Base class for Components providing content for wiki calendar.
    """

    def declare(self):
        """Returns an iterable of supported operations.

        Common values are pre-set here.
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:api.py

示例9: domain_functions

from trac.config            import Configuration
from trac.core              import implements
from trac.ticket.query      import Query
from trac.util.datefmt      import format_date, to_utimestamp
from trac.util.text         import to_unicode
from trac.util.translation  import domain_functions
from trac.web.href          import Href
from trac.web.chrome        import add_stylesheet, ITemplateProvider
from trac.wiki.api          import parse_args, IWikiMacroProvider, \
                                   WikiSystem
from trac.wiki.formatter    import format_to_html
from trac.wiki.macros       import WikiMacroBase

_, tag_, N_, add_domain = \
    domain_functions('wikiticketcalendar', '_', 'tag_', 'N_', 'add_domain')


__all__ = ['WikiTicketCalendarMacro', ]


class WikiTicketCalendarMacro(WikiMacroBase):
    """Display Milestones and Tickets in a calendar view.

    displays a calendar, the days link to:
     - milestones (day in bold) if there is one on that day
     - a wiki page that has wiki_page_format (if exist)
     - create that wiki page if it does not exist
     - use page template (if exist) for new wiki page
    """
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:29,代码来源:macro.py

示例10: domain_functions

import trac

from pkg_resources   import resource_filename

from trac.config     import BoolOption, Option
from trac.core       import *
from trac.perm       import PermissionSystem
from trac.web.api    import IRequestFilter, IRequestHandler
from trac.web.chrome import add_script, ITemplateProvider

# Import i18n methods.  Fallback modules maintain compatibility to Trac 0.11
# by keeping Babel optional here.
try:
    from trac.util.translation  import domain_functions
    add_domain, _ = \
        domain_functions('cc_selector', ('add_domain', '_'))
except ImportError:
    from trac.util.translation  import gettext
    _ = gettext
    def add_domain(a,b,c=None):
        pass


class TicketWebUiAddon(Component):
    implements(IRequestFilter, ITemplateProvider, IRequestHandler)

    show_fullname = BoolOption(
        'cc_selector', 'show_fullname', False,
        doc="Display full names instead of usernames if available.")
    username_blacklist = Option(
        'cc_selector', 'username_blacklist', '',
开发者ID:lkraav,项目名称:trachacks,代码行数:31,代码来源:cc_selector.py

示例11: domain_functions

# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.
#

from trac.config import Option, ListOption, IntOption
from trac.util import arity
from trac.util.translation import domain_functions, dgettext


TEXTDOMAIN = 'ticketcalendar'


_, tag_, N_, gettext, add_domain = domain_functions(
    TEXTDOMAIN,
    ('_', 'tag_', 'N_', 'gettext', 'add_domain'))


if arity(Option.__init__) <= 5:
    def _option_with_tx(Base): # Trac 0.12.x
        class Option(Base):
            def __getattribute__(self, name):
                val = Base.__getattribute__(self, name)
                if name == '__doc__':
                    val = dgettext(TEXTDOMAIN, val)
                return val
        return Option
else:
    def _option_with_tx(Base): # Trac 1.0 or later
        class Option(Base):
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:api.py

示例12: domain_functions

from trac.core import Component, implements
from trac.web.api import IRequestFilter, ITemplateStreamFilter
from trac.util.translation import domain_functions
from trac.web.chrome import ITemplateProvider, add_stylesheet, Chrome,\
    add_warning
from trac.config import ChoiceOption, Option
from genshi.filters import Transformer
from genshi import HTML
from pkg_resources import resource_filename #@UnresolvedImport
from genshi.builder import tag
from trac.wiki.api import WikiSystem
from genshi.core import Markup
from trac.util import as_int

_, tag_, N_, add_domain = \
    domain_functions('navigationplugin', '_', 'tag_', 'N_', 'add_domain')

SESSION_KEYS = {'nav': 'display_nav', 
                'wiki': 'wiki.href', 
                'tickets': 'tickets.href'}

DISPLAY_CHOICES = ['normal', 'buttom_ctx_menu', 'fixed_menu']
CHOICES_DOC = {'normal': 
               _("Trac default"), 
               'buttom_ctx_menu': 
               _("Display another context menu at the buttom of page"),
               'fixed_menu': 
               _("Display banner and menu fixed on top of page "
                 "(under development)")}

class Navigation(Component):
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:navigation.py

示例13: domain_functions

from trac.mimeview import Context
from trac.util.html import html
from trac.util.text import pretty_size
from trac.util.translation import domain_functions

# Trac interfaces.
from trac.web.main import IRequestHandler
from trac.web.chrome import INavigationContributor, ITemplateProvider
from trac.resource import IResourceManager
from trac.perm import IPermissionRequestor

# Local imports.
from tracdownloads.api import *

# Bring in dedicated Trac plugin i18n helper.
add_domain, _, tag_ = domain_functions('tracdownloads', ('add_domain', '_',
  'tag_'))

class DownloadsCore(Component):
    """
        The core module implements plugin's ability to download files, provides
        permissions and templates.
    """
    implements(IRequestHandler, ITemplateProvider, IPermissionRequestor,
      IResourceManager)

    # IPermissionRequestor methods.

    def get_permission_actions(self):
        view = 'DOWNLOADS_VIEW'
        add = ('DOWNLOADS_ADD', ['DOWNLOADS_VIEW'])
        admin = ('DOWNLOADS_ADMIN', ['DOWNLOADS_VIEW', 'DOWNLOADS_ADD'])
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:32,代码来源:core.py

示例14: domain_functions

# -*- coding: utf-8 -*-
import pkg_resources

from trac.util.translation import domain_functions


_, tag_, N_, add_tracpor_domain = \
            domain_functions('penelope.trac', ('_', 'tag_', 'N_', 'add_domain'))


def add_domains(env_path):
    locale_dir = pkg_resources.resource_filename(__name__, 'locale')
    add_tracpor_domain(env_path, locale_dir)
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:13,代码来源:i18n.py

示例15: domain_functions

#

"""Translation functions and classes."""

from pkg_resources import parse_version

from trac import __version__ as trac_version

#------------------------------------------------------
#    Internationalization
#------------------------------------------------------

try:
    from trac.util.translation import domain_functions
    _, ngettext, tag_, tagn_, gettext, N_, add_domain = \
        domain_functions('themeengine', ('_', 'ngettext', 'tag_', 'tagn_',
                                         'gettext', 'N_', 'add_domain'))
    dgettext = None
except ImportError:
    from genshi.builder  import tag as tag_
    from trac.util.translation  import gettext
    _ = gettext
    N_ = lambda text: text
    def add_domain(a,b,c=None):
        pass
    def dgettext(domain, string, **kwargs):
        return safefmt(string, kwargs)
    def ngettext(singular, plural, num, **kwargs):
        string = num == 1 and singular or plural
        kwargs.setdefault('num', num)
        return safefmt(string, kwargs)
    def safefmt(string, kwargs):
开发者ID:sebadima,项目名称:trac-bittercrm,代码行数:32,代码来源:translation.py


注:本文中的trac.util.translation.domain_functions函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。