Fossil Forum

Accept-Language and Server Extensions
Login

Accept-Language and Server Extensions

Accept-Language and Server Extensions

(1) By S. Ross Gohlke (rossgohlke) on 2023-05-12 23:03:18 [source]

Looking at extcgi.c, HTTP_ACCEPT_LANGUAGE is not in the list of environment variables passed to CGI Server Extensions.

As I see it, this request-header-turned-environment-variable is the key to localization in CGI Server Extensions. Am I missing something? Is there a security reason for this header not being passed?

(2) By Stephan Beal (stephan) on 2023-05-13 14:21:48 in reply to 1 [link] [source]

Am I missing something? Is there a security reason for this header not being passed?

It's simply never come up before. Fossil's never made any use of localization nor have we had any reports that anyone would like to localize a CGI extension.

It was just added to the trunk.

(3) By S. Ross Gohlke (rossgohlke) on 2023-05-13 17:46:06 in reply to 2 [link] [source]

Thank you, Stephan!

I have been investigating the Javascript implementation of Fluent (by Mozilla), fluent.js, for localization, and of course I want to serve it with Fossil.

I just downloaded and compiled the latest trunk and started a test server.

% ./configure
% make
% ./fossil init /tmp/scratch.fossil
% ./fossil server --extroot /path/to/ext /tmp/scratch.fossil

My super-simple CGI script shows an empty value for HTTP_ACCEPT_LANGUAGE but not HTTP_USER_AGENT.

#!/bin/sh   

echo "Content-type: text/html"

echo ""

echo "<HTML><BODY>"

echo "<H1>$HTTP_ACCEPT_LANGUAGE</H1>"
echo "<H1>$HTTP_USER_AGENT</H1>"

echo "</BODY></HTML>"

exit 0

I looked at the source code but did not see another obvious place where this variable could be blocked. I will keep looking.

(4) By Stephan Beal (stephan) on 2023-05-13 20:47:29 in reply to 3 [link] [source]

My super-simple CGI script shows an empty value for HTTP_ACCEPT_LANGUAGE but not HTTP_USER_AGENT.

... ./fossil server --extroot /path/to/ext /tmp/scratch.fossil

The part which translated the Accept-Language HTTP header into HTTP_ACCEPT_LANGUAGE was missing. Please try again with the latest trunk.

(5) By S. Ross Gohlke (rossgohlke) on 2023-05-14 15:38:30 in reply to 4 [link] [source]

Yes, with the new trunk, HTTP_ACCEPT_LANGUAGE is correctly passed to the Server Extension.

For anyone else who is interested in localization for CGI Server Extensions, I recommend starting with @fluent-web, the project's reference implementation for Javascript (other languages are also supported).