本文整理汇总了Python中silva.translations._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __call__
def __call__(self, form):
data, errors = form.extractData()
if errors:
return silvaforms.FAILURE
groupname = data.getDefault('group').strip()
service = component.getUtility(IGroupService)
groups = set()
new_groups = set()
try:
for group in service.find_groups(groupname, location=form.context):
groupid = group.groupid()
groups.add(groupid)
new_groups.add(groupid)
except MemberLookupError as error:
form.send_message(error.args[0], type="error")
return silvaforms.FAILURE
store = SessionStore(form.request)
if new_groups:
groups = store.get(GROUP_STORE_KEY, set()).union(groups)
store.set(GROUP_STORE_KEY, groups)
form.send_message(
_(u"Found ${count} groups: ${groups}.",
mapping={'count': len(new_groups),
'groups': u', '.join(new_groups)}),
type="feedback")
else:
form.send_message(
_(u"No matching groups found."),
type="error")
return silvaforms.FAILURE
return silvaforms.SUCCESS
开发者ID:silvacms,项目名称:silva.pas.base,代码行数:33,代码来源:smi.py
示例2: editor_roles_source
def editor_roles_source():
roles = [Term(value=None,
token='',
title=_(u"-- Choose a role --"))]
for role in roleinfo.AUTHOR_ROLES:
roles.append(Term(value=role, token=role, title=_(role)))
return Vocabulary(roles)
开发者ID:silvacms,项目名称:silva.core.contentlayout,代码行数:7,代码来源:interfaces.py
示例3: __call__
def __call__(self, form, authorization, line):
data, errors = form.extractData(form.fields)
if errors:
return silvaforms.FAILURE
role = data['role']
if not role:
return form.revoke(authorization, line)
mapping = {'role': role,
'username': authorization.identifier}
try:
if authorization.grant(role):
form.send_message(
_('Role "${role}" granted to user "${username}".',
mapping=mapping),
type="feedback")
else:
form.send_message(
_('User "${username}" already has the role "${role}".',
mapping=mapping),
type="error")
except UnauthorizedRoleAssignement as error:
form.send_message(
_(u'Sorry, you are not allowed to grant the role "${role}" '
u'to user "${username}": ${reason}.',
mapping={'role': error.role,
'username': error.identifier,
'reason': error.reason}),
type="error")
return silvaforms.SUCCESS
开发者ID:silvacms,项目名称:silva.core.smi,代码行数:29,代码来源:access.py
示例4: GET
def GET(self, intid=None, interface=None, show_index=False):
self.prepare()
if intid is not None:
try:
content = self.intid.getObject(int(intid))
except KeyError:
# Invalid content id
return self.json_response(
{
"id": "broken",
"type": "Broken",
"intid": "0",
"url": "",
"path": "",
"icon": self.get_icon(None),
"implements": False,
"folderish": False,
"title": self.translate(_(u"Missing content")),
"short_title": self.translate(_(u"Missing content")),
}
)
return self.json_response(self.get_item_details(content))
require = interfaces.ISilvaObject
if interface is not None:
require = getUtility(IInterface, name=interface)
return self.json_response(self.get_context_details(require=require, show_index=show_index))
开发者ID:silvacms,项目名称:silva.core.references,代码行数:26,代码来源:rest.py
示例5: dtformat
def dtformat(request, formatdate, currentdate=None):
"""Format a datetime object into a nice human like string.
"""
if currentdate is None:
currentdata = datetime.now()
dt = currentdate - formatdate
if isinstance(dt, float):
# XXX args are zope's DateTime instances rather than datetimes...
dt = timedelta(dt)
if dt.days > 28:
return str(formatdate)
parts = dtformat_timedelta(request, dt)
# translation helper
def _(str, **kwargs):
kwargs['context'] = request
kwargs['domain'] = 'silvaforum'
return translate(str, **kwargs)
if not parts:
return _('Just added')
if len(parts) > 2:
str_format = ', '.join(parts[:-1])
return _('Added ${time} ago', mapping={'time': str_format})
else:
str_format = ', '.join(parts)
return _('Added ${time} ago', mapping={'time': str_format})
开发者ID:silvacms,项目名称:Products.SilvaForum,代码行数:27,代码来源:dtformat.py
示例6: goto_column
def goto_column(settings, screen, cfg):
if settings.folder_goto_menu:
info = {'view': 'goto',
'index':
{'screen': 'content',
'caption': screen.translate(_(u"Go to"))},
'menu':
[{'screen': 'preview',
'caption': screen.translate(_(u"Preview"))},
{'screen': 'properties',
'caption': screen.translate(_(u"Properties")),
'item_match':
['not', ['equal', 'access', None]]},
{'screen': 'publish',
'caption': screen.translate(_(u"Publish")),
'item_match':
['and',
['not', ['equal', 'access', None]],
['provides', 'versioned']]},
{'screen': 'settings/access',
'caption': screen.translate(_(u"Access")),
'item_match':
['and',
['equal', 'access', 'manage'],
['provides', 'container']]}]}
cfg.add(info, GOTO_WIDTH)
开发者ID:silvacms,项目名称:silva.ui,代码行数:26,代码来源:listing.py
示例7: authenticated_role_vocabulary
def authenticated_role_vocabulary():
terms = [SimpleTerm(value=None, token='None', title=_(u'select:')),
SimpleTerm(value='Authenticated',
token='Authenticated',
title=_('Authenticated'))]
_add_silva_role(terms)
return SimpleVocabulary(terms)
开发者ID:silvacms,项目名称:silva.core.interfaces,代码行数:7,代码来源:auth.py
示例8: GET
def GET(self):
"""Return a message after the user successfully logged in.
"""
return self.json_response({
'content': {
'ifaces': ['message'],
'title': self.translate(_(u'Logged in')),
'message': self.translate(_(u'You are now authenticated.'))}})
开发者ID:silvacms,项目名称:silva.pas.base,代码行数:8,代码来源:smi.py
示例9: render
def render(self, view=None):
content = self.content
if content is None:
return _(u'Content reference is broken or missing.')
block_view = queryMultiAdapter((content, self.request), IBlockView)
if block_view is None:
return _(u'Content is not viewable.')
return block_view()
开发者ID:silvacms,项目名称:silva.core.contentlayout,代码行数:8,代码来源:contents.py
示例10: __call__
def __call__(self, form):
manager = IOrderManager(form.context, None)
if manager is not None:
if manager.repair(form.context.objectValues()):
form.send_message(_("Container order was repaired."),
type=u"feedback")
return silvaforms.SUCCESS
form.send_message(_("Container order is consistent."), type=u"feedback")
return silvaforms.SUCCESS
开发者ID:silvacms,项目名称:silva.core.smi,代码行数:9,代码来源:settings.py
示例11: url_validation
def url_validation(content):
if content.relative and not content.target:
raise interface.Invalid(
_(u"Relative link selected without target."))
if not content.relative and not content.url:
raise interface.Invalid(
_(u"Absolute link selected without URL. "
u"If the link goes to an internal item in Silva, "
u"put a checkmark in the relative link field."))
开发者ID:silvacms,项目名称:Products.Silva,代码行数:9,代码来源:Link.py
示例12: get_orientation
def get_orientation(self):
"""Returns translated Image orientation (string).
"""
width, height = self.get_dimensions()
if width == height:
return _("square")
elif width > height:
return _("landscape")
return _("portrait")
开发者ID:silvacms,项目名称:Products.Silva,代码行数:9,代码来源:content.py
示例13: sort_order_source
def sort_order_source():
orders = []
for key, title in [
('silva', _(u'Silva folder order')),
('alpha', _(u'Alphabetically')),
('reversealpha', _(u'Reverse alphabetically')),
('chronmod', _(u'Chronologically by modification date')),
('rchronmod', _(u'Reverse chronologically by modification date'))]:
orders.append(SimpleTerm(value=key, token=key, title=title))
return SimpleVocabulary(orders)
开发者ID:silvacms,项目名称:Products.Silva,代码行数:10,代码来源:views.py
示例14: __verify_copyable
def __verify_copyable(self, content):
if not content.cb_isCopyable():
return ContainerError(
_(u"You are unauthorized to copy this content."),
content)
if content.meta_type not in self.__addables:
return ContainerError(
_(u"You cannot add this content type in this container."),
content)
return None
开发者ID:silvacms,项目名称:Products.Silva,代码行数:10,代码来源:management.py
示例15: _status_to_string
def _status_to_string(self, status):
if status == self.CONTAINS_BAD_CHARS:
return _(u'The id contains strange characters. It should only '
u'contain letters, digits and ‘_’ or ‘-’ or ‘.’ '
u'Spaces are not allowed and the id should start '
u'with a letter or digit.')
elif status == self.RESERVED_PREFIX:
prefix = str(self._maybe_id).split('_')[0]+'_'
return _(u"ids starting with ${prefix} are reserved for "
u"internal use.",
mapping={'prefix': prefix})
elif status == self.RESERVED:
return _(u"The id ${id} is reserved for internal use.",
mapping={'id': self._maybe_id})
elif status == self.IN_USE_CONTENT:
return _(u"There is already an object with the id ${id} in this "
u"container.",
mapping={'id': self._maybe_id})
elif status == self.IN_USE_ASSET:
return _(u"There is already an asset with the id ${id} in this "
u"container.", mapping={'id': self._maybe_id})
elif status == self.RESERVED_POSTFIX:
return _(u"The id ${id} ends with invalid characters.",
mapping={'id': self._maybe_id})
elif status == self.IN_USE_ZOPE:
return _(u"The id ${id} is already in use by a Zope object.",
mapping={'id': self._maybe_id})
elif status == self.RESERVED_FOR_CONTENT:
return _("The id ${id} cannot be used for a content of this "
u"type.", mapping={'id': self._maybe_id})
return _(u"(Internal Error): An invalid status ${status_code} occured "
u"while checking the id ${id}.",
mapping={'status_code': status, 'id': self._maybe_id})
开发者ID:silvacms,项目名称:Products.Silva,代码行数:33,代码来源:mangle.py
示例16: remove
def remove(self):
values, errors = self.extractData()
if not values.get("usedMarkers", None):
self.send_message(_(u"You need to select a marker."), type=u"error")
return silvaforms.FAILURE
manager = IMarkManager(self.context)
for value in values["usedMarkers"]:
manager.remove_marker(value)
self.send_message(_(u"Marker removed."), type=u"feedback")
return silvaforms.SUCCESS
开发者ID:silvacms,项目名称:silva.core.smi,代码行数:11,代码来源:makers.py
示例17: validate_slot_identifier
def validate_slot_identifier(value, form):
if value is silvaforms.NO_VALUE:
return _(u'Identifier required.')
if not VALIDATE_SLOT_ID_RE.match(value):
return _(u'Invalid identifier.')
slots = form.context.slots
if value in slots:
current_slot = form.getContentData().getContent().block
if current_slot != slots[value]:
return _(u'A slot with that identifier already exists.')
return None
开发者ID:silvacms,项目名称:silva.core.contentlayout,代码行数:11,代码来源:slot.py
示例18: reindex
def reindex(self):
data, errors = self.extractData()
if errors:
return
path = data['path']
try:
self.context.reindex_subtree(path)
except KeyError:
self.status = _(u"Invalid path")
else:
self.status = _(u"Partial catalog refreshed")
开发者ID:silvacms,项目名称:Products.Silva,代码行数:11,代码来源:ExtensionService.py
示例19: save
def save(self):
self.errors = self.binding.setValuesFromRequest(
self.request, reindex=1)
if self.errors:
self.send_message(_(
'The data that was submitted did not '
'validate properly. Please adjust '
'the form values and submit again.'), type='error')
return silvaforms.FAILURE
self.send_message(_('Metadata saved.'), type='feedback')
return silvaforms.SUCCESS
开发者ID:silvacms,项目名称:silva.core.smi,代码行数:11,代码来源:metadata.py
示例20: delete_site
def delete_site(self):
if not self.is_site():
raise ValueError(_(u'Not a local site.'))
if interfaces.IRoot.providedBy(self.context):
raise ValueError(_(u"Can't disable local site on Silva Root."))
sm = ISite(self.context).getSiteManager()
if list(sm.registeredAdapters()):
raise ValueError(_(u'Still have registered customizations.'))
if list(sm.registeredUtilities()):
raise ValueError(_(u'Still have registered services.'))
disableSite(self.context)
开发者ID:silvacms,项目名称:Products.Silva,代码行数:11,代码来源:localsite.py
注:本文中的silva.translations._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论