html: Apply appropriate "lang" attributes

Primarily so that browsers can choose the correct font for CJK pages.
This commit is contained in:
Yorhel 2021-12-16 16:25:58 +01:00
parent f57c474932
commit b39d038811

View file

@ -195,7 +195,7 @@ sub framework_ {
my $content = pop; my $content = pop;
my(%o) = @_; my(%o) = @_;
html_ sub { html_ lang => 'en', sub {
head_ sub { head_ sub {
link_ rel => 'stylesheet', type => 'text/css', href => '/man.css?5'; link_ rel => 'stylesheet', type => 'text/css', href => '/man.css?5';
title_ $o{title}.' - manned.org'; title_ $o{title}.' - manned.org';
@ -630,7 +630,7 @@ TUWF::get qr{/([^/]+)/([0-9a-f]{8})/src} => sub {
sub man_nav_ { sub man_nav_ {
my($man, $toc) = @_; my($man, $toc, $htmllang) = @_;
my @systems = tuwf->dbAlli(' my @systems = tuwf->dbAlli('
SELECT DISTINCT p.system SELECT DISTINCT p.system
@ -713,7 +713,7 @@ sub man_nav_ {
ul_ sub { ul_ sub {
for (0..$#$toc) { for (0..$#$toc) {
li_ sub { li_ sub {
a_ href => sprintf('#head%d', $_+1), lc $toc->[$_]; a_ @$htmllang, href => sprintf('#head%d', $_+1), lc $toc->[$_];
} }
} }
} }
@ -767,10 +767,11 @@ sub man_page {
AND f.shorthash <> ', \shorthash_to_int($man->{shorthash}), ' AND f.shorthash <> ', \shorthash_to_int($man->{shorthash}), '
LIMIT 1' LIMIT 1'
); );
my @htmllang = $man->{locale} =~ /^([a-z]{2,3})(?:_([A-Z]{2}))?(?:$|@|\.)/ ? (lang => $1.($2?"-$2":'')) : ();
tuwf->resLastMod($man->{released}); tuwf->resLastMod($man->{released});
framework_ title => $man->{name}, mainclass => 'manpage', sub { framework_ title => $man->{name}, mainclass => 'manpage', sub {
man_nav_ $man, \@toc; man_nav_ $man, \@toc, \@htmllang;
# TODO: Replace the 'versions' and 'locations' functionality with non-JS alternatives. # TODO: Replace the 'versions' and 'locations' functionality with non-JS alternatives.
div_ id => 'manbuttons', sub { div_ id => 'manbuttons', sub {
h1_ $man->{name}; h1_ $man->{name};
@ -785,7 +786,7 @@ sub man_page {
} }
}; };
div_ id => 'manres', class => 'hidden', ''; div_ id => 'manres', class => 'hidden', '';
pre_ sub { lit_ $fmt }; pre_ @htmllang, sub { lit_ $fmt };
}; };
} }