Re: do we need i18n when serving static files ?
"John P. Rouillard" <[email protected]> Thu, 28 Apr 2022 09:00:59 -0400
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Marcus: In message <[email protected]>, Marcus Priesch writes: >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 Would i18n processing for static assets allow me to have feedback messages in English in a javascript file (consider strings in a dict) that are translated using roundup's i18n? This way there is no need to add a javascript based i18n mechanism. I have written javascript in html templates that are processed through roundup's i18n mechanism and then referenced by js loaded through script src=... references. >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. I assume you need roundup's i18n mechanism to translate things like status names etc. in the rest response right? So optimizing out i18n from the rest flow doesn't seem like it would work. I don't see an advantage to trying to do a translation in javascript as you would have two sets of translation files (web and javascript for rest or xmlrpc for that matter) that need to be maintained/synced etc. But maybe I do not understand your proposal. Have a great day. -- -- rouilj John Rouillard =========================================================================== My employers don't acknowledge my existence much less my opinions.