do we need i18n when serving static files ?
Marcus Priesch <[email protected]> Thu, 28 Apr 2022 12:07:19 +0200
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Organization | priesch.co.at - open source consulting |
| Message-ID | <[email protected]> |
Hi there,
upon looking for when get_translation actually gets called i found out
that it gets also called when serving static files via @@file...
as far as i understand the code in Client.py determine_context raises an
exception for special cases:
SendFile:
for files attached to issues, which can result in Unauthorized and
therefore would need i18n for the error page
SendStaticFile:
for static assets neede by the page - which imho dont need i18n
moving the call to self.determine_language down the code results in only
one call to get_translation (for the class url) and no calls for static
files:
self._error_message = []
try:
self.determine_charset()
- self.determine_language()
try:
# make sure we're identified (even anonymously)
self.determine_user()
# figure out the context and desired content template
self.determine_context()
+ self.determine_language()
+
# if we've made it this far the context is to a bit of
# Roundup's real web interface (not a file being
served up)
and within the SendFile exception:
except SendFile as designator:
# The call to serve_file may result in an Unauthorised
# exception or a NotModified exception. Those
# exceptions will be handled by the outermost set of
# exception handlers.
+ self.determine_language()
self.serve_file(designator)
what do you think ?
background: i am working on a dynamic js frontend which heavily uses the
rest api and am now in the process of improving the performance per request.
regards,
marcus.
--
Marcus Priesch
open source consultant - solution provider
www.priesch.co.at / [email protected]
A-2122 Riedenthal, In Prandnern 31 / +43 650 62 72 870