Commit bbbb341a authored by Paul Wise's avatar Paul Wise

Language buttons: support hiding unsupported languages for the current page

This also hides the button for the current language.

This will be useful if we move the buttons to being on every page.

Extends: commit c646e774
parent 65305cbb
......@@ -310,18 +310,30 @@ sub language_selector_button {
sub language_selector_buttons {
$base_url = "$(HOME)";
$file = "$(WML_SRC_BASENAME)";
$cur_lang = "$(CUR_LANG)";
$cwd = $WML_SRC_DIRNAME;
$full_base_url = &canonpath("$cwd/$base_url");
$rel_dir = &relpath( $full_base_url, $cwd );
$rel_dir =~ s,/$,,;
my $file_langs = shift // 0;
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{$_} } = $_;
if ( $file_langs ) {
foreach ( keys %langs ) {
if (( -f "$base_url/../$_/$rel_dir/$file.wml" ) || ( -f "$base_url/../$_/$rel_dir/$file.src" )) {
if ( $_ ne lc($cur_lang) or $cur_lang eq "Chinese" ) {
$sorted_langs{ $selflang{$_} } = $_;
}
}
}
} else {
foreach ( keys %langs ) {
$sorted_langs{ $selflang{$_} } = $_;
}
}
foreach ( sort langcmp keys %sorted_langs ) {
......
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