« lib/Mojolicious/Plugin/Fondation/Command/fondation.pm
↑ Summary
lib/Mojolicious/Plugin/Fondation/Manager.pm »
| 1 | package Mojolicious::Plugin::Fondation::Controller::Welcome; | ||
| 2 | $Mojolicious::Plugin::Fondation::Controller::Welcome::VERSION = '0.08'; | ||
| 3 | # ABSTRACT: Welcome page controller with language-aware template selection | ||
| 4 | |||
| 5 | use Mojo::Base 'Mojolicious::Plugin::Fondation::Controller::Base', -signatures; | ||
| 6 | |||
| 7 | sub index ($self) { | ||
| 8 | $self->render_later; | ||
| 9 | my $c = $self; | ||
| 10 | my $lang = $c->stash('i18n_lang'); | ||
| 11 | unless ($lang) { | ||
| 12 | ($lang) = ($c->req->headers->accept_language // '') =~ /^([a-z]{2})/i; | ||
| 13 | $lang //= 'en'; | ||
| 14 | } | ||
| 15 | |||
| 16 | # Only 'en' and 'fr' exist; fall back to 'en' for anything else | ||
| 17 | $lang = 'en' unless $lang eq 'fr'; | ||
| 18 | |||
| 19 | my $has_setup = exists $c->app->fondation->registry->{'Mojolicious::Plugin::Fondation::Setup'}; | ||
| 20 | |||
| 21 | $c->render( | ||
| 22 | template => "welcome_$lang", | ||
| 23 | has_setup => $has_setup, | ||
| 24 | ); | ||
| 25 | } | ||
| 26 | |||
| 27 | 1; | ||
| 28 | |||
| 29 | __END__ |