Commit c646e774 authored by Paul Wise's avatar Paul Wise

Add support for the new content negotiation override cookie

Document that the cookie exists on the content negotiation page.
parent be94aded
......@@ -26,3 +26,5 @@ to the version of that page in every other language available.
This is computed using a perl script called by wml when the
page is generated.
<P>There is also an option to override the browser language preferences
using a cookie that prioritises a single language over the browser preferences.
......@@ -29,13 +29,16 @@ listed at the bottom of a page) will only show the current page in that
language. It does <em>not</em> change the default language. If you click a
link to a different page, it will be shown in the original language again.
To change your <em>default</em> language, you need to change your language
preferences in the configuration of your browser, as explained below.</p>
preferences in the configuration of your browser.
If that isn't possible you can override your browser language preferences.
These options are explained below.</p>
<p>You can also find additional information about selecting language preferences on this
<a href="http://www.w3.org/International/questions/qa-lang-priorities">W3C page</a>.</p>
<ul>
<li><a href="#fix">What to do if a Debian web page is in the wrong language</a></li>
<li><a href="#override">How to override the language settings</a></li>
<li><a href="#howtoset">How to set up the language settings</a></li>
<li>Where to change the settings for the following browsers:
<toc-display /></li>
......@@ -69,6 +72,11 @@ cache (both disk and memory) in your browser before trying to view pages again.
We also suggest you use <a href="https://packages.debian.org/stable/web/lynx">lynx</a> when testing. It is the only browser we have
found to comply 100% with the HTTP specifications for content negotiation.</p>
<p>
It is better to set your language preferences in your browser settings but
as a last resort you can <a href="#override">override the preferred language</a>.
</p>
<h3><a name="cache">Potential problems with proxy servers</a></h3>
<p>Proxy servers are essentially web servers that have no content of their
......@@ -93,6 +101,30 @@ for them to upgrade or replace their software.</p>
<hr />
<h2><a name="override">How to override the language settings</a></h2>
<p>
If you are not able to <a href="#howtoset">set the preferred languages</a>
in your browser, device or computing environment,
then you can override your browser preferences
using the language buttons below.
This will set a single language as
preferred over the languages
that your browser reports as your preferences.
</p>
<p>
Please note that this will set a
<a href="https://en.wikipedia.org/wiki/HTTP_cookie">cookie</a>
that contains your language selection.
Your browser will delete the cookie if you do not visit this website for a month.
You can delete the cookie now by choosing the "Browser default" option.
</p>
<protect pass=2>
<: print language_selector_buttons(); :>
</protect>
<h2><a name="howtoset">How to set up the language settings</a></h2>
<p>You should set the preferred language to all the languages you speak,
......
......@@ -283,4 +283,61 @@ sub languages_footer {
}
}
sub language_selector_form {
my $path = shift;
my $text = shift;
my $title = shift;
$title = qq{title="$title" } if defined $title;
my $form = qq{
<form style="display: inline;" method="POST" action="$path">
<input value="$text" ${title}type="submit">
</form>
};
return $form;
}
sub language_selector_button {
my $lang = shift;
my $path = shift;
my $tooltip = shift;
my $text = shift;
$path = "/intro/cn/setlang/$langs{$cur_lang}$path";
$text .= "&nbsp;($translit{$lang})"
if defined $translit{$lang};
return language_selector_form($path, $text, $tooltip)
}
sub language_selector_buttons {
$base_url = "$(HOME)";
$file = "$(WML_SRC_BASENAME)";
$cwd = $WML_SRC_DIRNAME;
$full_base_url = &canonpath("$cwd/$base_url");
$rel_dir = &relpath( $full_base_url, $cwd );
$rel_dir =~ s,/$,,;
my $path = shift // "/$rel_dir/$file";
my $str = '';
$str .= language_selector_form("/intro/cn/unsetlang$path", '<gettext>Browser default</gettext>', '<gettext>Unset the language override cookie</gettext>');
foreach ( keys %langs ) {
$sorted_langs{ $selflang{$_} } = $_;
}
foreach ( sort langcmp keys %sorted_langs ) {
$cur_lang = $sorted_langs{$_};
$tooltip = $trans{$CUR_ISO_LANG}{$cur_lang};
if ( $cur_lang ne "chinese" ) {
$str .= language_selector_button($cur_lang, $path, $tooltip, $_);
}
else {
$str .= language_selector_button("$cur_lang-cn", $path, "$tooltip (".country_name('CN').')', "$_(&#31616;)");
$str .= language_selector_button("$cur_lang-hk", $path, "$tooltip (".country_name('HK').')', "$_(HK)");
$str .= language_selector_button("$cur_lang-tw", $path, "$tooltip (".country_name('TW').')', "$_(&#32321;)");
}
}
return $str;
}
</perl>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment