• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python translation.domain_functions函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Apache

#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.


r"""Project dashboard for Apache(TM) Bloodhound

Translation functions and classes.
"""

from trac.util.translation import domain_functions

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

_, ngettext, tag_, tagn_, gettext, N_, add_domain = \
   domain_functions('bhdashboard', ('_', 'ngettext', 'tag_', 'tagn_',
                                'gettext', 'N_', 'add_domain'))
开发者ID:mohsadki,项目名称:dargest,代码行数:30,代码来源:translation.py


示例17: return

        return (self.realm, self.category)

    def get_session_terms(self, session_id):
        return tuple()

_TRUE_VALUES = ('yes', 'true', 'enabled', 'on', 'aye', '1', 1, True)

def istrue(value, otherwise=False):
    return True and (value in _TRUE_VALUES) or otherwise


try:
    from trac.util.translation import domain_functions

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

except ImportError:
    # fall back to 0.11 behavior, i18n functions are no-ops then
    def add_domain():
        pass

    _ = N_ = tag_ = _noop = lambda string: string
    pass


class AnnouncementSystem(Component):
    """AnnouncementSystem represents the entry-point into the announcement
    system, and is also the central controller that handles passing notices
    around.
开发者ID:lkraav,项目名称:trachacks,代码行数:30,代码来源:api.py


示例18: web_context

from trac.web.chrome import Chrome, ITemplateProvider, add_stylesheet, \
                            add_script, add_script_data
from trac.util.text import to_unicode, unicode_unquote
from trac.util.translation import domain_functions

try:
    from trac.web.chrome import web_context
except ImportError:
    from trac.mimeview.api import Context
    def web_context(*args, **kwargs):
        return Context.from_request(*args, **kwargs)


__all__ = ['TracDragDropModule']

add_domain, _ = domain_functions('tracdragdrop', 'add_domain', '_')


def _list_message_files(dir):
    if not os.path.isdir(dir):
        return set()
    return set(file[0:-3] for file in os.listdir(dir) if file.endswith('.js'))


class TracDragDropModule(Component):
    implements(ITemplateProvider, IRequestFilter, IRequestHandler,
               ITemplateStreamFilter, IEnvironmentSetupParticipant)

    htdocs_dir = resource_filename(__name__, 'htdocs')
    templates_dir = resource_filename(__name__, 'templates')
    messages_files = _list_message_files(os.path.join(htdocs_dir, 'messages'))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:web_ui.py


示例19: domain_functions

from trac.config import BoolOption, ListOption, Option
from trac.core import Component, ExtensionPoint, Interface, TracError
from trac.core import implements
from trac.perm import IPermissionPolicy, IPermissionRequestor
from trac.perm import PermissionError, PermissionSystem
from trac.resource import IResourceManager, get_resource_url
from trac.resource import get_resource_description
from trac.util import get_reporter_id
from trac.util.text import to_unicode
from trac.util.translation import domain_functions
from trac.wiki.model import WikiPage

# Import translation functions.
add_domain, _, N_, gettext, ngettext, tag_, tagn_ = \
    domain_functions('tractags', ('add_domain', '_', 'N_', 'gettext',
                                  'ngettext', 'tag_', 'tagn_'))
dgettext = None

from tractags.model import resource_tags, tag_frequency, tag_resource
from tractags.model import tagged_resources
# Now call module importing i18n methods from here.
from tractags.query import *

REALM_RE = re.compile('realm:(\w+)', re.U | re.I)


class Counter(dict):
    """Dict subclass for counting hashable objects.

    Sometimes called a bag or multiset.  Elements are stored as dictionary
    keys and their counts are stored as dictionary values.
开发者ID:kzhamaji,项目名称:TracTagsPlugin,代码行数:31,代码来源:api.py


示例20: Copyright

#
# Copyright (C) 2012-2013 MATOBA Akihiro <[email protected]>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.

from genshi.builder import tag
from genshi.filters.transform import Transformer
from pkg_resources import ResourceManager
from trac.core import Component, implements
from trac.util.translation import domain_functions
from trac.web.api import IRequestFilter, ITemplateStreamFilter
from trac.web.chrome import ITemplateProvider, add_script

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

# functionality that implemented:
#  - hide specified fields
#  - add hide field button
#  - undone hiding fields


class HideFieldChanges(Component):
    implements(IRequestFilter, ITemplateProvider, ITemplateStreamFilter)

    # IRequestFilter methods
    def pre_process_request(self, req, handler):
        # when show a ticket, add script for 'hide customfield' buttons
        if req.path_info.startswith('/ticket'):
            add_script(req, 'hidefieldchanges/js/hidefieldchanges.js')
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:ticket.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python translation.tag_函数代码示例发布时间:2022-05-27
下一篇:
Python translation._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap