How to use the invenio.base.i18n._ function in invenio

To help you get started, we’ve selected a few invenio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inveniosoftware / invenio / invenio / modules / tags / views.py View on Github external
form = EditTagForm(request.values, csrf_enabled=False, obj=tag)

    if form.validate_on_submit():
        form.populate_obj(tag)

        name_count = db.session.query(WtgTAG).\
            filter_by(id_user=id_user, name=tag.name).count()

        if name_count == 1:
            db.session.add(tag)
            db.session.commit()
            flash(_('Tag Successfully edited.'), 'success')

        else:
            flash(_('Tag name') + ' <strong>' + escape(tag.name) +
                  '</strong> ' + _('is already in use.'), 'error(html_safe)')

    return dict(tag=tag, form=form)
github inveniosoftware / invenio / invenio / modules / messages / views.py View on Github external
def add(msg_reply_id):
    from invenio.utils.mail import email_quote_txt
    uid = current_user.get_id()
    if msg_reply_id:
        if (dblayer.check_user_owns_message(uid, msg_reply_id) == 0):
            flash(_('Sorry, this message in not in your mailbox.'), "error")
            return redirect(url_for('.index'))
        else:
            try:
                m = dbquery.get_message(uid, msg_reply_id)
                message = MsgMESSAGE()
                message.sent_to_user_nicks = m.message.user_from.nickname \
                    or str(m.message.id_user_from)
                message.subject = _("Re:") + " " + m.message.subject
                message.body = email_quote_txt(m.message.body)
                form = AddMsgMESSAGEForm(request.form, obj=message)
                return render_template('messages/add.html', form=form)
            except db.sqlalchemy.orm.exc.NoResultFound:
                # The message exists in table user_msgMESSAGE
                # but not in table msgMESSAGE => table inconsistency
                flash(_('This message does not exist.'), "error")
            except:
                flash(_('Problem with loading message.'), "error")

            return redirect(url_for('.index'))

    form = AddMsgMESSAGEForm(request.values)
    if form.validate_on_submit():
        m = MsgMESSAGE()
        form.populate_obj(m)
github inveniosoftware / invenio / invenio / modules / knowledge / api.py View on Github external
# get the highest id to calculate the new name
            result = db.session.execute(
                db.select([models.KnwKB.id])
                .order_by(db.desc(models.KnwKB.id))
                .limit(1)).first()
            index = result[0] + 1 if result is not None else 1
            name = kb_name + " " + str(index)
            i = i + 1
            created = False
        except Exception:
            db.session.rollback()
            raise

    if created is False:
        # TODO raise the right exception
        raise Exception(_("Can't create knowledge base \"%(name)s\".\n"
                          "Probabily the server is busy! "
                          "Try again later.", name=kb_name))

    return kb.id
github inveniosoftware / invenio / invenio / modules / access / local_config.py View on Github external
('claimpaperoperators', 'claimpaper_change_others_data', {}),
             ('holdingpenusers', 'viewholdingpen', {}),
             ('depositusers', 'usedeposit', {}),
             )


# Activities (i.e. actions) for which exists an administrative web interface.
CFG_ACC_ACTIVITIES_URLS = {
    'runbibedit' : (_("Run Record Editor"), "%s/%s/edit/?ln=%%s" % (CFG_SITE_URL, CFG_SITE_RECORD)),
    'runbibeditmulti' : (_("Run Multi-Record Editor"), "%s/%s/multiedit/?ln=%%s" % (CFG_SITE_URL, CFG_SITE_RECORD)),
    'runbibdocfile' : (_("Run Document File Manager"), "%s/%s/managedocfiles?ln=%%s" % (CFG_SITE_URL, CFG_SITE_RECORD)),
    'runbibmerge' : (_("Run Record Merger"), "%s/%s/merge/?ln=%%s" % (CFG_SITE_URL, CFG_SITE_RECORD)),
    'runbibswordclient' : (_("Run BibSword client"), "%s/bibsword/?ln=%%s" % CFG_SITE_URL),
    'cfgbibknowledge' : (_("Configure BibKnowledge"), "%s/kb?ln=%%s" % CFG_SITE_URL),
    'cfgbibformat' : (_("Configure BibFormat"), "%s/admin/bibformat/bibformatadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgoaiharvest' : (_("Configure OAI Harvest"), "%s/admin/oaiharvest/oaiharvestadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgoairepository' : (_("Configure OAI Repository"), "%s/admin/oairepository/oairepositoryadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgbibindex' : (_("Configure BibIndex"), "%s/admin/bibindex/bibindexadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgbibrank' : (_("Configure BibRank"), "%s/admin/bibrank/bibrankadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgwebaccess' : (_("Configure WebAccess"), "%s/admin/webaccess/webaccessadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgwebcomment' : (_("Configure WebComment"), "%s/admin/webcomment/webcommentadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgweblinkback' : (_("Configure WebLinkback"), "%s/admin/weblinkback/weblinkbackadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgwebsearch' : (_("Configure WebSearch"), "%s/admin/websearch/websearchadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgwebsubmit' : (_("Configure WebSubmit"), "%s/admin/websubmit/websubmitadmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgwebjournal' : (_("Configure WebJournal"), "%s/admin/webjournal/webjournaladmin.py?ln=%%s" % CFG_SITE_URL),
    'cfgbibsort' : (_("Configure BibSort"), "%s/admin/bibsort/bibsortadmin.py?ln=%%s" % CFG_SITE_URL),
    'runbibcirculation' : (_("Run BibCirculation"), "%s/admin/bibcirculation/bibcirculationadmin.py?ln=%%s" % CFG_SITE_URL),
    'runbatchuploader' : (_("Run Batch Uploader"), "%s/batchuploader/metadata?ln=%%s" % CFG_SITE_URL),
    'runinfomanager' : (_("Run Info Space Manager"), "%s/info/manage?ln=%%s" % CFG_SITE_URL),
    'claimpaper_claim_others_papers' : (_("Run Person/Author Manager"), "%s/author/search?ln=%%s" % CFG_SITE_URL)
}
github inveniosoftware / invenio / invenio / modules / messages / forms.py View on Github external
if field.data:
        test = set(msg_split_addr(field.data))
        comp = set([u for u, in db.session.query(Usergroup.name).
                    filter(Usergroup.name.in_(test)).all()])
        diff = test.difference(comp)
        if len(diff) > 0:
            raise validators.ValidationError(
                _('Not valid groups: %(x_group)s', x_group=(', '.join(diff))))


class AddMsgMESSAGEForm(InvenioBaseForm):

    """Define form for writing new message."""

    sent_to_user_nicks = StringField(_('Users'), [validate_user_nicks])
    sent_to_group_names = StringField(_('Groups'), [validate_group_names])
    subject = StringField(_('Subject'))
    body = TextAreaField(_('Message'), [
        validators.length(
            0, CFG_WEBMESSAGE_MAX_SIZE_OF_MESSAGE,
            message=_(
                "Your message is too long, please edit it. "
                "Maximum size allowed is %{length}i characters.",
                length=CFG_WEBMESSAGE_MAX_SIZE_OF_MESSAGE
            )
        )
    ])
    received_date = DateTimeField(_('Send later'), [validators.optional()],
                                  widget=DateTimePickerWidget())

    def validate_sent_to_user_nicks(self, field):
        """Check whenever user nickname or group name was posted."""
github inveniosoftware / invenio / invenio / modules / search / user_settings.py View on Github external
def __init__(self):
        super(WebSearchSettings, self).__init__()
        self.icon = 'search'
        self.title = _('Searches')
        self.view = '/youralerts/display'  # FIXME url_for('youralerts.index')
        self.edit = url_for('webaccount.edit', name=self.name)
github inveniosoftware / invenio / invenio / modules / groups / views.py View on Github external
    _('%(icon)s Groups', icon='<i class="fa fa-group fa-fw"></i>'),
    order=0,
    active_when=lambda: request.endpoint.startswith("webgroup.")
)
@register_breadcrumb(blueprint, '.', _('Groups'))
@login_required
@permission_required('usegroups')
def index():
    """List all user groups."""
    uid = current_user.get_id()
    current_user.reload()
    form = JoinUsergroupForm()
    form.id_usergroup.set_remote(
        url_for('webgroup.search_groups', id_user=uid) +
        "?query=%QUERY")
    user = User.query.get(uid)
    uugs = dict(map(lambda uug: (uug.usergroup.name, uug),
github zenodo / zenodo / zenodo / modules / accessrequests / forms.py View on Github external
def validate_message(form, field):
        """Validate message."""
        if form.reject.data and not field.data.strip():
            raise validators.ValidationError(
                _("You are required to provide message to the requester when"
                  " you reject a request.")
github inveniosoftware / invenio / invenio / modules / deposit / forms / article.py View on Github external
export_key='abstract.summary',
        widget=ckeditor_widget,
    )
    pagesnum = fields.PagesNumberField(label=_('Number of Pages'))
    languages = [("en", _("English")),
                 ("fre", _("French")),
                 ("ger", _("German")),
                 ("dut", _("Dutch")),
                 ("ita", _("Italian")),
                 ("spa", _("Spanish")),
                 ("por", _("Portuguese")),
                 ("gre", _("Greek")),
                 ("slo", _("Slovak")),
                 ("cze", _("Czech")),
                 ("hun", _("Hungarian")),
                 ("pol", _("Polish")),
                 ("nor", _("Norwegian")),
                 ("swe", _("Swedish")),
                 ("fin", _("Finnish")),
                 ("rus", _("Russian"))]
    language = fields.LanguageField(label=_('Language'), choices=languages)
    date = fields.Date(label=_('Date of Document'), widget=date_widget,
                       export_key='imprint.date')

    authors = fields.DynamicFieldList(
        fields.FormField(
            AuthorForm,
            widget=ExtendedListWidget(
                item_widget=ListItemWidget(with_label=False, class_="col-sm-6 col-xs-6 no-padding"),
                class_='collection-item list-unstyled',
            ),
        ),
github inveniosoftware / invenio / invenio / modules / access / views / admin.py View on Github external
actions = [
        dict(url=url_for('.rolearea'),
             title=_('Role Area'),
             description=_('Main area to configure administration rights '
                           'and authorization rules.')),
        dict(url=url_for('.actionarea'),
             title=_('Action Area'),
             description=_('Configure administration rights with the '
                           'actions as starting point.')),
        dict(url=url_for('.userarea'),
             title=_('User Area'),
             description=_('Configure administration rights with the '
                           'users as starting point.')),
        dict(url=url_for('.resetarea'),
             title=_('Reset Area'),
             description=_('Reset roles, actions and authorizations.')),
        dict(url=url_for('.manageaccounts'),
             title=_('Manage Accounts Area'),
             description=_('Manage user accounts.')),
        dict(url=url_for('.delegate_startarea'),
             title=_('Delegate Rights - With Restrictions'),
             description=_('Delegate your rights for some roles.')),
    ]
    return dict(actions=actions)