本文整理汇总了Python中django.utils.translation.gettext_noop方法的典型用法代码示例。如果您正苦于以下问题:Python translation.gettext_noop方法的具体用法?Python translation.gettext_noop怎么用?Python translation.gettext_noop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.translation
的用法示例。
在下文中一共展示了translation.gettext_noop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: safe_summary
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import gettext_noop [as 别名]
def safe_summary(self, encoded):
algorithm, iterations, salt, hash = encoded.split('$', 3)
assert algorithm == self.algorithm
return OrderedDict([
(_('algorithm'), algorithm),
(_('iterations'), iterations),
(_('salt'), mask_hash(salt)),
(_('hash'), mask_hash(hash)),
])
示例2: harden_runtime
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import gettext_noop [as 别名]
def harden_runtime(self, password, encoded):
_, data = encoded.split('$', 1)
salt = data[:29] # Length of the salt in bcrypt.
rounds = data.split('$')[2]
# work factor is logarithmic, adding one doubles the load.
diff = 2**(self.rounds - int(rounds)) - 1
while diff > 0:
self.encode(password, force_bytes(salt))
diff -= 1
示例3: _get_result_data
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import gettext_noop [as 别名]
def _get_result_data(results):
return {
'categories': [
# Using gettext_noop here since this will be tacked into the cache, so it must be language neutral.
# The caller, SubmissionList.get_result_data will run ugettext on the name.
{'code': 'AC', 'name': gettext_noop('Accepted'), 'count': results['AC']},
{'code': 'WA', 'name': gettext_noop('Wrong'), 'count': results['WA']},
{'code': 'CE', 'name': gettext_noop('Compile Error'), 'count': results['CE']},
{'code': 'TLE', 'name': gettext_noop('Timeout'), 'count': results['TLE']},
{'code': 'ERR', 'name': gettext_noop('Error'),
'count': results['MLE'] + results['OLE'] + results['IR'] + results['RTE'] + results['AB'] + results['IE']},
],
'total': sum(results.values()),
}
示例4: create_pootle_permissions
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import gettext_noop [as 别名]
def create_pootle_permissions(self):
"""Create Pootle's directory level permissions."""
args = {
"app_label": "pootle_app",
"model": "directory",
}
pootle_content_type = self._create_object(ContentType, **args)[0]
pootle_content_type.save()
# Create the permissions.
permissions = [
{"name": _("Can access a project"), "codename": "view"},
{"name": _("Cannot access a project"), "codename": "hide"},
{
"name": _("Can make a suggestion for a translation"),
"codename": "suggest",
},
{"name": _("Can submit a translation"), "codename": "translate"},
{"name": _("Can review suggestions"), "codename": "review"},
{
"name": _("Can perform administrative tasks"),
"codename": "administrate",
},
]
criteria = {
"content_type": pootle_content_type,
}
for permission in permissions:
criteria.update(permission)
self._create_object(Permission, **criteria)
示例5: harden_runtime
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import gettext_noop [as 别名]
def harden_runtime(self, password, encoded):
_, data = encoded.split('$', 1)
salt = data[:29] # Length of the salt in bcrypt.
rounds = data.split('$')[2]
# work factor is logarithmic, adding one doubles the load.
diff = 2**(self.rounds - int(rounds)) - 1
while diff > 0:
self.encode(password, salt.encode('ascii'))
diff -= 1
示例6: test_from_gettext
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import gettext_noop [as 别名]
def test_from_gettext():
gstr = gettext_noop('Welcome')
lstr = LazyI18nString.from_gettext(gstr)
assert 'de' in lstr.data
assert lstr.data['en'] == 'Welcome'
示例7: handle
# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import gettext_noop [as 别名]
def handle(self, *args, **options):
NoticeType.create(
"create_meeting_slot",
_("Periodo de reunion creada"),
_("tu periodo de reunion esta lista"),
)
NoticeType.create(
"reserved_meeting_slot",
_("Reunion aceptada"),
_("tu reunion ha sido aceptada"),
)
NoticeType.create(
"cancelled_by_mentor",
_("Reunion cancelada por el mentor"),
_("tu reunion ha sido cancelada"),
)
NoticeType.create(
"cancelled_by_protege",
_("Reunion cacelada por aprendiz"),
_("your meeting has been cancelled"),
)
NoticeType.create(
"confirmed_meeting",
_("Reunion confirmada"),
_("su reunion ha sido confirmada"),
)
NoticeType.create(
"post_meeting_mentor", _("Dejenos saber"), _("como le fue en su reunion?")
)
NoticeType.create(
"post_meeting_protege", _("Dejenos saber"), _("como le fue en su reunion?")
)
NoticeType.create(
"comment", _("Comentario nuevo"), _("tienes un nuevo comentario")
)
self.stdout.write("--> Created notice types")