Permalink
Browse files

Always show localized content to admin users

  • Loading branch information...
1 parent 124862e commit 3d7020d6d5647d571739b77d63b37f995096e2ec @autarch autarch committed Dec 10, 2012
Showing with 18 additions and 8 deletions.
  1. +5 −2 lib/VegGuide.pm
  2. +12 −4 lib/VegGuide/Client.pm
  3. +1 −2 share/mason/lib/form/entry.mas
View
@@ -59,8 +59,11 @@ sub client {
my $locale;
$locale = $location->locale() if $location;
- return $stash->{client}
- = VegGuide::Client->new( $self->request(), $locale );
+ return $stash->{client} = VegGuide::Client->new(
+ $self->request(),
+ $locale,
+ $self->vg_user()->is_admin(),
+ );
}
{
@@ -21,9 +21,12 @@ sub new {
my $class = shift;
my $request = shift;
my $locale = shift;
+ my $always = shift;
my $self = bless {}, $class;
+ $self->{always_localize} = $always;
+
$self->_get_encodings($request);
$self->_get_languages($request);
@@ -32,8 +35,12 @@ sub new {
$self->{encoding} = $encoding;
- if ( $locale->language_code ne 'en'
- && $self->{possible_languages}{ $locale->language_code } ) {
+ if (
+ $self->{always_localize}
+ || ( $locale->language_code ne 'en'
+ && $self->{possible_languages}{ $locale->language_code } )
+ ) {
+
$self->{show_localized_content} = 1;
}
}
@@ -100,8 +107,9 @@ sub localize_for_location {
return if $locale->language_code() =~ /^en/i;
return 1
- if $self->show_utf8
- && $self->accepts_language( $locale->language_code );
+ if $self->{always_localize}
+ || ( $self->show_utf8
+ && $self->accepts_language( $locale->language_code ) );
}
sub _encoding_for_locale {
@@ -330,8 +330,7 @@ else
}
my $client_wants_localized_fields
- = $c->client()->localize_for_location($location)
- || ( $c->vg_user()->is_admin() && $c->request()->params()->{localize} );
+ = $c->client()->localize_for_location($location);
</%init>
<%def .categories>

0 comments on commit 3d7020d

Please sign in to comment.