Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • cubicweb cubicweb
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 185
    • Issues 185
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 20
    • Merge requests 20
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cubicwebcubicweb
  • cubicwebcubicweb
  • Issues
  • #87
Closed
Open
Issue created Oct 21, 2020 by Nicola Spanti@nspantiMaintainer

No translation in pviews

Problem

In a pview, from cubicweb import _ and self._cw._ do not translate, so it just returns the string that was given as argument. It is also the case of self._cw.user._cw._.

Remarks

  • However self._cw.user.prefered_language() returns a good result.
  • It is at least the case with version 3.26.18 of CubicWeb.

Technical notes

From where is it given?

Stack trace of a pview

File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/tweens.py, line 41, function excview_tween:
  response = handler(request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/cubicweb/pyramid/bwcompat.py, line 192, function __call__:
  response = self.handler(request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/router.py, line 148, function handle_request:
  registry, request, context, context_iface, view_name
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/view.py, line 667, function _call_view:
  response = view_callable(context, request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/config/views.py, line 169, function __call__:
  return view(context, request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/config/views.py, line 188, function attr_view:
  return view(context, request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/config/views.py, line 214, function predicate_wrapper:
  return view(context, request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/viewderivers.py, line 384, function authdebug_view:
  return view(context, request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/viewderivers.py, line 436, function rendered_view:
  result = view(context, request)
File /home/nspanti/.virtualenvs/nemo/local/lib/python2.7/site-packages/pyramid/viewderivers.py, line 144, function _requestonly_view:
  response = view(request)

Research in CubicWeb source code

  1. def _cw_cnx(request) of cubicweb/pyramid/core.py
  2. Session.new_cnx of cubicweb/pyramid/core.py
  3. Connection (with good session._cached_lang and so self.lang) of cubicweb/pyramid/core.py
  4. Connection of cubicweb/server/session.py
# cubicweb/req.py

    def set_language(self, lang):
        """install i18n configuration for `lang` translation.

        Raises :exc:`KeyError` if translation doesn't exist.
        """
        self.lang = lang
        try:
            gettext, pgettext = self.vreg.config.translations[lang]
        except KeyError:
            assert self.vreg.config.mode == 'test'
            gettext = text_type

            def pgettext(x, y):
                return text_type(y)

        # use _cw.__ to translate a message without registering it to the catalog
        self._ = self.__ = gettext
        self.pgettext = pgettext
Edited Dec 10, 2020 by Nicola Spanti
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking