summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--data/script.js2
-rw-r--r--lib/VNDB/Handler/Misc.pm15
-rwxr-xr-xutil/vndb.pl12
4 files changed, 21 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index d23e431d..ea2f908a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@ git - ?
- Automatically generate the skin credits on d7, by reading the skin files
- Only tagmods can create top-level tags
- Notification system (still only used for PMs)
+ - Removed the ?l10n= paremeter
2.10 - 2010-01-10
- VN score on tag pages use plain averages instead of bayesian rating
diff --git a/data/script.js b/data/script.js
index bd4dd144..437385cd 100644
--- a/data/script.js
+++ b/data/script.js
@@ -1951,7 +1951,7 @@ if(byId('lang_select')) {
var icon = tag('acronym', {'class':'icons lang '+ln}, ' ');
lst.appendChild(tag('li', {'class':'lang_selector'}, mt_curlang == ln
? tag('i', icon, mt('_lang_'+ln))
- : tag('a', {href:'?l10n='+ln}, icon, L10N_STR['_lang_'+ln][ln]||mt('_lang_'+ln))
+ : tag('a', {href:'/setlang?lang='+ln}, icon, L10N_STR['_lang_'+ln][ln]||mt('_lang_'+ln))
));
}
return lst;
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index e2fdaa62..de4bdd67 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -13,6 +13,7 @@ YAWF::register(
qr{}, \&homepage,
qr{(?:([upvr])([1-9]\d*)/)?hist}, \&history,
qr{d([1-9]\d*)}, \&docpage,
+ qr{setlang}, \&setlang,
qr{nospam}, \&nospam,
qr{we-dont-like-ie6}, \&ie6message,
qr{opensearch\.xml}, \&opensearch,
@@ -328,6 +329,20 @@ sub docpage {
}
+sub setlang {
+ my $self = shift;
+
+ my $lang = $self->formValidate({name => 'lang', required => 1, enum => [ VNDB::L10N::languages ]});
+ return 404 if $lang->{_err};
+ $lang = $lang->{lang};
+
+ (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$self->{url}//;
+ $self->resRedirect($ref, 'post');
+ $self->resHeader('Set-Cookie', "l10n=$lang; expires=Sat, 01-Jan-2030 00:00:00 GMT; path=/; domain=$self->{cookie_domain}")
+ if $lang ne $self->{l10n}->language_tag();
+}
+
+
sub nospam {
my $self = shift;
$self->htmlHeader(title => mt '_nospam_title', noindex => 1);
diff --git a/util/vndb.pl b/util/vndb.pl
index ee617caa..29c2648c 100755
--- a/util/vndb.pl
+++ b/util/vndb.pl
@@ -54,18 +54,14 @@ sub reqinit {
my $self = shift;
# Determine language
- # if the cookie or parameter "l10n" is set, use that.
- # otherwise, interpret the Accept-Language header or fall back to English
+ # if the cookie is set, use that. Otherwise, interpret the Accept-Language header or fall back to English.
# if the cookie is set and is the same as either the Accept-Language header or the fallback, remove it
- my $conf = $self->reqParam('l10n') || $self->reqCookie('l10n');
+ my $conf = $self->reqCookie('l10n');
$conf = '' if !$conf || !grep $_ eq $conf, VNDB::L10N::languages;
$self->{l10n} = VNDB::L10N->get_handle(); # this uses I18N::LangTags::Detect
- if($self->{l10n}->language_tag() eq $conf && $self->reqCookie('l10n')) {
- $self->resHeader('Set-Cookie', "l10n= ; expires=Sat, 01-Jan-2000 00:00:00 GMT; path=/; domain=$self->{cookie_domain}");
- } elsif($self->reqParam('l10n') && $conf && $conf ne ($self->reqCookie('l10n')||'') && $self->{l10n}->language_tag() ne $conf) {
- $self->resHeader('Set-Cookie', "l10n=$conf; expires=Sat, 01-Jan-2030 00:00:00 GMT; path=/; domain=$self->{cookie_domain}");
- }
+ $self->resHeader('Set-Cookie', "l10n= ; expires=Sat, 01-Jan-2000 00:00:00 GMT; path=/; domain=$self->{cookie_domain}")
+ if $conf && $self->{l10n}->language_tag() eq $conf;
$self->{l10n} = VNDB::L10N->get_handle($conf) if $conf && $self->{l10n}->language_tag() ne $conf;