kiwix / libkiwix

Common code base for all Kiwix ports
https://download.kiwix.org/release/libkiwix/
GNU General Public License v3.0
112 stars 55 forks source link

UI language preference ignored for kiwix-serve error pages #1019

Closed veloman-yunkan closed 5 months ago

veloman-yunkan commented 8 months ago

After #997 the text on error pages is in the language detected from the value of the "Accept-Language" header (i.e. the browser language preference), ignoring the kiwix-serve front-end UI language preference (since the information about the user-selected language is no longer sent to the server).

kelson42 commented 8 months ago

@veloman-yunkan This been a regresssion AFAIK it has to be fixed in priority

veloman-yunkan commented 7 months ago

I can see three ways to fix this issue:

  1. Include information about the UI language in every HTTP request so that the backend can generate the error message in the correct language (which is conceptually equivalent to reverting #997). This is the easiest option.

  2. Translate the error page in the front-end. The error page must be amended or replaced with structured information (parameters) from which the final HTML in the target language can be generated by JS. This solution will require the most effort.

  3. Translate the error page in the back-end. Once the front-end receives non-translated error page from the backend, it repeats the request with the user language explicitly specified in the URL so that the backend can regenerate the same page in the requested language. This solution is relatively easy if we can ignore the following:

    • non-deterministic errors, when a retry may succeed.
    • computation heavy requests that end with an error - this approach increases the load on the server.
mgautierfr commented 7 months ago

Could we have a 4th solution when server return a structured information to the client instead of a html error page, then the client amend the information with the user language and it does a request to a new specific endpoint on the server which will generate the html page ?

veloman-yunkan commented 7 months ago

Could we have a 4th solution when server return a structured information to the client instead of a html error page, then the client amend the information with the user language and it does a request to a new specific endpoint on the server which will generate the html page ?

@mgautierfr I liked the idea initially, but on a second thought implementing it won't be significantly easier than performing the translation fully in the front-end. Yet it made the latter approach seem more doable so I am going to pursue option 2.