As noted by Pasi Kallinen, the language picker would not reflect the
chosen locale unless your cookie had been set or there was an explicit
CGI parameter with the locale name.
Accordingly, get the default locale from the context vars and use that
to set the selected value for the language picker in the absence of
anything else, to prevent the picker from possibly confusingly showing
the first language alphabetically rather than the currently displayed
language in the rest of the UI.
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Pasi Kallinen <pasi.kallinen@pttk.fi>
Signed-off-by: Ben Shum <bshum@biblio.org>
[%- IF ctx.locales.keys.size > 1;
- set_locale = CGI.param('set_eg_locale') || CGI.cookie('eg_locale');
+
+ # Ensure the context locale is in xx_yy format
+ base_locale = ctx.locale FILTER lower;
+ base_locale = base_locale.replace('-','_');
+
+ set_locale = CGI.param('set_eg_locale') || CGI.cookie('eg_locale') || base_locale;
%]
<form id="locale_picker_form" action="[% mkurl() %]" method="post">
<label for="locale_picker">[% l("Language:") %]</label>