本文整理汇总了Python中nagare.i18n._L函数的典型用法代码示例。如果您正苦于以下问题:Python _L函数的具体用法?Python _L怎么用?Python _L使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_L函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, pager):
filters_by_name = dict(map(lambda f: (f.name, f), pager().filters))
# state names
state_names = ['SUGGESTED_STEP', 'SELECTED_STEP',
'PROJECT_STEP', 'PROTOTYPE_STEP', 'EXTENDED_STEP',
'refused']
if pager()._transform != 'progressing_ideas':
state_names = ['STUDY_STEP', ] + state_names
if pager()._transform == 'user':
state_names.insert(0, 'SUBMITTED_STEP')
filter_state = [filters_by_name[name] for name in state_names]
self.filter_menu_state = FilterMenu(filter_state, 'state', pager)
period_names = ['last_day', 'last_week', 'last_month']
filter_period = [filters_by_name[name] for name in period_names]
self.filter_menu_period = FilterMenu(filter_period, 'period', pager)
filter_domain = [filter for filter in pager().filters if isinstance(filter, IdeaDomainFilter)]
self.filter_menu_domain = FilterMenu(filter_domain, 'domain', pager)
filter_challenge = [filter for filter in pager().filters if isinstance(filter, IdeaChallengeFilter)]
self.filter_menu_challenge = FilterMenu(filter_challenge, 'challenge', pager)
self.menu_state = component.Component(PagerMenu(_L(u'state'), self.filter_menu_state, pager, pager().change_filter_state))
self.menu_challenge = component.Component(PagerMenu(_L(u'challenge'), self.filter_menu_challenge, pager, pager().change_filter_challenge))
self.menu_period = component.Component(PagerMenu(_L(u'period'), self.filter_menu_period, pager, pager().change_filter_period))
self.menu_domain = component.Component(PagerMenu(_L(u'domain'), self.filter_menu_domain, pager, pager().change_filter_domain))
self.menu_state().attach_linked_menu([self.menu_challenge(), self.menu_period(), self.menu_domain()])
self.menu_challenge().attach_linked_menu([self.menu_state(), self.menu_period(), self.menu_domain()])
self.menu_period().attach_linked_menu([self.menu_challenge(), self.menu_state(), self.menu_domain()])
self.menu_domain().attach_linked_menu([self.menu_challenge(), self.menu_period(), self.menu_state()])
开发者ID:droodle,项目名称:eureka-opensource,代码行数:35,代码来源:activity.py
示例2: initialization
def initialization(self):
""" Initialize Kansha application
Initialize user_menu with current user,
Initialize last board
Return:
- app initialized
"""
user = security.get_user()
self.home_menu['boards'] = MenuEntry(
_L(u'Boards'),
'board',
self.boards_manager
)
self.home_menu['profile'] = MenuEntry(
_L(u'Profile'),
'user',
self._services(
get_userform(
self.app_title, self.app_banner, self.theme, user.data.source
),
user.data,
)
)
self.user_menu = component.Component(user)
if user and self.content() is None:
self.select_last_board()
return self
开发者ID:nagareproject,项目名称:kansha,代码行数:29,代码来源:comp.py
示例3: validate_file
def validate_file(data, max_size=None,
msg=_L(u'Size must be less than %d KB')):
"""
Validate a 'file' input data against the max size in KB
"""
# check against the first roundtrip with the client
if data is None or is_string(data):
return None
if data.done == -1:
raise ValueError(_L(u'Transfer was interrupted'))
# gets the file size (it's a StringIO)
data.file.seek(0, 2) # 0 from EOF
filesize = data.file.tell()
data.file.seek(0)
if max_size is not None and filesize > max_size * 1024:
raise ValueError(msg % max_size)
filedata = data.file.read()
filename = ntpath.basename(unicode(data.filename))
return {'filename': filename,
'filedata': filedata,
'content_type': unicode(data.type)}
开发者ID:droodle,项目名称:eureka-opensource,代码行数:26,代码来源:validators.py
示例4: __init__
def __init__(self, app_title, app_banner, custom_css, user, search_engine, services_service):
"""
In:
- ``user`` -- user (DataUser instance)
"""
self.app_title = app_title
self.menu = OrderedDict()
self.menu['boards'] = MenuEntry(
_L(u'Boards'),
services_service(
UserBoards,
app_title,
app_banner,
custom_css,
user,
)
)
self.menu['my-cards'] = MenuEntry(
_L(u'My cards'),
services_service(UserCards, user, search_engine)
)
self.menu['profile'] = MenuEntry(
_L(u'Profile'),
services_service(
get_userform(
app_title, app_banner, custom_css, user.source
),
user,
)
)
self.content = component.Component(None)
self._on_menu_entry(next(iter(self.menu)))
开发者ID:gpaugam,项目名称:kansha,代码行数:33,代码来源:user_profile.py
示例5: __init__
def __init__(self, app_title, app_banner, custom_css, user, mail_sender, assets_manager, search_engine):
"""
In:
- ``user`` -- user (DataUser instance)
- ``mail_sender`` -- MailSender instance
"""
self.app_title = app_title
self.menu = collections.OrderedDict()
self.menu['boards'] = MenuEntry(
_L(u'Boards'),
UserBoards(
app_title,
app_banner,
custom_css,
[dbm.board for dbm in user.board_members],
mail_sender,
assets_manager
)
)
self.menu['my-cards'] = MenuEntry(
_L(u'My cards'),
UserCards(user, assets_manager, search_engine)
)
self.menu['profile'] = MenuEntry(
_L(u'Profile'),
get_userform(
app_title, app_banner, custom_css, user.source
)(user, mail_sender, assets_manager)
)
self.content = component.Component(None)
self._on_menu_entry(next(iter(self.menu)))
开发者ID:droodle,项目名称:kansha,代码行数:32,代码来源:user_profile.py
示例6: __init__
def __init__(self, idea):
super(WorkflowSection, self).__init__()
self.idea_id = idea if is_integer(idea) else idea.id
self.switching_menu = component.Component(WorkflowMenu(self.idea_id, switching_actions))
event_management._register_listener(self, self.switching_menu())
recommendation_legend = _L(u'After my appraisal i can propose two kinds of suggestion:')
self.recommendation_menu = component.Component(
WorkflowMenu(self.idea_id, recommendation_actions, recommendation_legend))
event_management._register_listener(self, self.recommendation_menu())
self.evaluation_menu = component.Component(EvaluationMenu(self.idea_id))
self.tabs = (('switching', _L(u'My actions'), self.switching_menu),
('evaluation', _L(u"My evaluation"), self.evaluation_menu),
('recommendation', _L(u"My recommendation"), self.recommendation_menu))
self.selected_tab = editor.Property('switching')
self.menu_items = [(label, name, None, '', None) for name, label, action in self.filtered_tabs]
self.menu = component.Component(Menu([], self.filter_menu), model='tab_renderer')
self.menu.on_answer(self.select_tab)
if self.menu_items:
self.select_tab(0)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:26,代码来源:comp.py
示例7: fi_states_labels
def fi_states_labels():
workflow = get_workflow()
return (
(workflow.WFStates.FI_NORMALIZE_STATE, _L(u'You have %d ideas to review')),
(workflow.WFStates.AUTHOR_NORMALIZE_STATE, _L(u'You have sent back %d ideas to innovators')),
(workflow.WFStates.DI_APPRAISAL_STATE, _L(u'You have sent %d ideas to developers')),
(workflow.WFStates.FI_REFUSED_STATE, _L(u'You have refused %d ideas')),
)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:8,代码来源:basket.py
示例8: validate_email
def validate_email(value, required_msg=_L("Required field"), invalid_msg=_L("Invalid email address")):
"""Check that the value is a valid email address"""
if not value:
raise ValueError(_(required_msg))
# convert to lowercase
value = value.lower()
if len(value) > 7:
if re.match(MAIL_RE, value):
return value
raise ValueError(_(invalid_msg))
开发者ID:Reigel,项目名称:kansha,代码行数:13,代码来源:validators.py
示例9: __init__
def __init__(self, app_title, custom_css, user, mail_sender, assets_manager, search_engine):
"""
In:
- ``user`` -- user (DataUser instance)
- ``mail_sender`` -- MailSender instance
"""
self.app_title = app_title
self.menu = ((_L(u'Boards'), UserBoards(app_title, custom_css, [dbm.board for dbm in user.board_members], mail_sender, assets_manager)),
(_L(u'My cards'), UserCards(
user, assets_manager, search_engine)),
(_L(u'Profile'), get_userform(app_title, custom_css, user.source)(
user, mail_sender, assets_manager)),
)
self.content = component.Component(None)
self.select(self.menu[0][0])
开发者ID:ygravrand,项目名称:kansha,代码行数:15,代码来源:user_profile.py
示例10: user_email_list
def user_email_list(text, separator=',', check_user_email=True):
"""Validate a list of email addresses between commas"""
emails = [item.strip() for item in text.split(separator) if
item.strip() != '']
if not emails:
raise ValueError(_L(u"Can't be empty"))
for email in emails:
if not validateEmail(email):
raise ValueError(_L(u"%s is not a valid email address") % email)
if check_user_email and not UserRepository().get_by_email(email):
raise ValueError(
_L(u"There's no user with this email address: %s") % email)
return emails
开发者ID:droodle,项目名称:eureka-opensource,代码行数:16,代码来源:validators.py
示例11: in_words_list
def in_words_list(text, separator=',', required=False, duplicates='warn',
words=()):
values = word_list(text, separator=separator, required=required,
duplicates=duplicates)
bad_words = set(values) - set(words)
if bad_words:
bad_words = list(bad_words)
if len(bad_words) < 2:
raise ValueError(_L(u"%s is not a valid value") % bad_words[0])
else:
raise ValueError(
_L(u"%s are not valid values") % ', '.join(bad_words))
return values
开发者ID:droodle,项目名称:eureka-opensource,代码行数:16,代码来源:validators.py
示例12: is_identifier
def is_identifier(self, msg=_L('Should start with an ASCII letter and '
'contain only ASCII letters or digits')):
"""Validate an identifier"""
if not self.value:
return self
return self.match(IDENTIFIER_RE, msg)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:7,代码来源:validators.py
示例13: di_states_labels
def di_states_labels():
workflow = get_workflow()
return (
(workflow.WFStates.DI_APPRAISAL_STATE, _L(u'You have %d ideas to review')),
(workflow.WFStates.DSIG_BASKET_STATE, _L(u'You have sent %d ideas to DSIG')),
(workflow.WFStates.DI_REFUSED_STATE, _L(u'You have refused %d ideas')),
(workflow.WFStates.DI_APPROVED_STATE, _L(u'You have approved %d ideas')),
(workflow.WFStates.SELECTED_STATE, _L(u'You have %d selected ideas')),
(workflow.WFStates.PROJECT_STATE, _L(u'You have %d projected ideas')),
(workflow.WFStates.PROTOTYPE_STATE, _L(u'You have %d prototyped ideas')),
(workflow.WFStates.EXTENDED_STATE, _L(u'You have %d extended ideas')),
)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:12,代码来源:basket.py
示例14: __init__
def __init__(self, v, strip=True, rstrip=False, lstrip=False, chars=None,
msg=_L(u'Must be a string')):
# fix a nagare bug where StringValidator accepts None but fail in the not_empty check
if v is not None and not is_string(v): # we accept None or a string
raise ValueError(msg)
if v is None: # strip will crash if the given value is None...
strip = False
super(ExtendedStringValidator, self).__init__(remove_invalid_chars(v),
strip, rstrip, lstrip,
chars)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:11,代码来源:validators.py
示例15: word_list
def word_list(text, separator=',', required=False, duplicates='warn'):
if not text:
if required:
raise ValueError(_L(u"Can't be empty"))
return []
words = [item.strip() for item in text.split(separator) if
item.strip() != '']
duplicates_handlers = {
'ignore': (lambda w: w),
'warn': check_duplicates,
'remove': remove_duplicates,
}
return duplicates_handlers[duplicates](words)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:15,代码来源:validators.py
示例16: is_email
def is_email(self, msg=_L(u"Must be an email address")):
"""Check that the value is an email
In:
- ``msg`` -- message to raise
Return:
- ``self``
"""
if not self.value:
return self
if validateEmail(self.value):
return self
raise ValueError(msg)
开发者ID:droodle,项目名称:eureka-opensource,代码行数:16,代码来源:validators.py
示例17: is_user_email
def is_user_email(self, msg=_L(u"No user with this email")):
"""Check that there is a known user with this email
In:
- ``msg`` -- message to raise
Return:
- ``self``
"""
if not self.value:
return self
if not UserRepository().get_by_email(self.value):
raise ValueError(msg)
return self
开发者ID:droodle,项目名称:eureka-opensource,代码行数:16,代码来源:validators.py
示例18: is_unused_uid
def is_unused_uid(self, msg=_L(u'User id already used')):
"""Check that there is no user with this identifier
In:
- ``msg`` -- message to raise
Return:
- ``self``
"""
if not self.value:
return self
if UserRepository().get_by_uid(self.value):
raise ValueError(msg)
return self
开发者ID:droodle,项目名称:eureka-opensource,代码行数:16,代码来源:validators.py
示例19: _L
from nagare.namespaces import xhtml
from sqlalchemy.types import TypeDecorator
import sqlalchemy as sa
from user.models import DataBoardMember
# Levels
NOTIFY_OFF = 0
NOTIFY_MINE = 1
NOTIFY_ALL = 2
# Groups and messages
EVENT_MESSAGES = {
'card_create': _L(u'Card "%(card)s" has been added to column "%(column)s"'),
'card_delete': _L(u'User %(author)s has deleted card "%(card)s"'),
'card_archive': _L(u'User %(author)s has archived card "%(card)s"'),
'card_move': _L(u'Card "%(card)s" has been moved from column "%(from)s" to column "%(to)s"'),
'card_title': _L(u'Card "%(from)s" has been renamed to "%(to)s"'),
'card_weight': _L(u'Card "%(card)s" has been weighted from (%(from)s) to (%(to)s)'),
'card_add_member': _L(u'User %(user)s has been assigned to card "%(card)s"'),
'card_remove_member': _L(u'User %(user)s has been unassigned from card "%(card)s"'),
'card_add_comment': _L(u'User %(author)s has commented card "%(card)s"'),
'card_add_file': _L(u'User %(author)s has added file "%(file)s" to card "%(card)s"'),
'card_add_list': _L(u'User %(author)s has added the checklist "%(list)s" to card "%(card)s"'),
'card_delete_list': _L(u'User %(author)s has deleted the checklist "%(list)s" from card "%(card)s"'),
'card_listitem_done': _L(u'User %(author)s has checked the item %(item)s from the checklist "%(list)s", on card "%(card)s"'),
'card_listitem_undone': _L(u'User %(author)s has unchecked the item %(item)s from the checklist "%(list)s", on card "%(card)s"'),
}
开发者ID:ygravrand,项目名称:kansha,代码行数:30,代码来源:notifications.py
示例20: validate_non_empty_string
def validate_non_empty_string(value, msg=_L("Required field")):
"""Check that the value is a non-empty string"""
# strip whitespace characters
return validator.StringValidator(value, strip=True).not_empty(_(msg)).to_string()
开发者ID:Reigel,项目名称:kansha,代码行数:4,代码来源:validators.py
注:本文中的nagare.i18n._L函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论