summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-08-15 09:05:48 +0200
committerYorhel <git@yorhel.nl>2009-08-17 16:27:14 +0200
commitc000490dcdf208e235a05358668dbb6fb70d5168 (patch)
tree010eaf25e66f7b7aeeac972d796c843669df1159
parent4b918796f8d85d40d55dbf2674a2b691d802ff02 (diff)
Added language switcher to the main menu
-rw-r--r--data/lang.txt13
-rw-r--r--data/style.css4
-rw-r--r--lib/VNDB/L10N.pm4
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm11
-rwxr-xr-xutil/vndb.pl6
5 files changed, 24 insertions, 14 deletions
diff --git a/data/lang.txt b/data/lang.txt
index cd6cd010..eb6774b8 100644
--- a/data/lang.txt
+++ b/data/lang.txt
@@ -40,15 +40,6 @@ indicate that it has been checked.
/intro
-:test
-en : (en test)
-ru : (ru test)
-
-:multiline
-en : en multi
- en line
-
-ru : ru multi
- ru line
-
+:Menu
+ru : ~[Menu in russian~]
diff --git a/data/style.css b/data/style.css
index c904a18a..4bc97b19 100644
--- a/data/style.css
+++ b/data/style.css
@@ -272,6 +272,10 @@ b.future {
font-size: 11px;
color: $maintext$;
}
+#menulist h2 span {
+ float: right;
+ padding-top: 1px;
+}
#menulist dt {
display: block;
float: left;
diff --git a/lib/VNDB/L10N.pm b/lib/VNDB/L10N.pm
index cbf6a239..5540c710 100644
--- a/lib/VNDB/L10N.pm
+++ b/lib/VNDB/L10N.pm
@@ -8,6 +8,10 @@ use warnings;
sub fallback_languages { ('en') };
+ # used for the language switch interface, language tags must
+ # be the same as in the languages hash in global.pl
+ sub languages { ('en', 'ru') }
+
# can be called as either a subroutine or a method
sub loadfile {
my %lang = (
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index b5813330..a932c5a1 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -54,7 +54,16 @@ sub _menu {
div id => 'menulist';
div class => 'menubox';
- h2 'Menu';
+ h2;
+ span;
+ for (grep $self->{l10n}->language_tag() ne $_, $self->{l10n}->languages()) {
+ a href => "?l10n=$_";
+ cssicon "lang $_", $self->{languages}{$_};
+ end;
+ }
+ end;
+ txt mt 'Menu';
+ end;
div;
a href => '/', 'Home'; br;
a href => '/v/all', 'Visual novels'; br;
diff --git a/util/vndb.pl b/util/vndb.pl
index 7dd9b6fa..b7c83393 100755
--- a/util/vndb.pl
+++ b/util/vndb.pl
@@ -48,8 +48,10 @@ YAWF::init(
sub reqinit {
my $self = shift;
- # TODO: get language from user setting (cookie, query string, whatever)
- $self->{l10n} = VNDB::L10N->get_handle();
+ $self->{l10n} = VNDB::L10N->get_handle($self->reqParam('l10n') || $self->reqCookie('l10n') || ());
+ my $lang = $self->{l10n}->language_tag();
+ $self->resHeader('Set-Cookie', "l10n=$lang; expires=Sat, 01-Jan-2030 00:00:00 GMT; path=/; domain=$self->{cookie_domain}")
+ if $lang ne ($self->reqCookie('l10n')||'');
$self->authInit;