Commit b3328d78 authored by seb leridon's avatar seb leridon

LUTECE-2278 : context locales management

parent addde278
......@@ -264,9 +264,10 @@ public final class PortalService
String strWebmasterEmail = DatastoreService.getDataValue( KEY_WEBMASTER_EMAIL, "" );
model.put( Markers.WEBMASTER_EMAIL, strWebmasterEmail );
locale = LocaleService.getContextUserLocale( request );
if ( request != null )
{
locale = LocaleService.getUserSelectedLocale( request );
user = SecurityService.getInstance( ).getRegisteredUser( request );
if ( nMode != MODE_ADMIN )
{
......@@ -297,7 +298,7 @@ public final class PortalService
if ( request != null )
{
String strLastModified = DateUtil.getDateString( data.getDateUpdate( ), request.getLocale( ) );
String strLastModified = DateUtil.getDateString( data.getDateUpdate( ), locale );
model.put( MARK_LAST_MODIFIED, strLastModified );
}
HtmlTemplate tFooter = AppTemplateService.getTemplate( strFooter, locale, model );
......@@ -329,6 +330,8 @@ public final class PortalService
}
model.put( Markers.ENCODING, strEncoding );
model.put( Markers.USER_CONTEXT_LANGUAGE, locale);
model.put( MARK_IS_EXTEND_INSTALLED, isExtendActivated( ) );
......
......@@ -115,6 +115,7 @@ public class AdminPageJspBean extends AdminFeaturesPageJspBean
private static final String MARK_AUTORIZATION = "authorization";
private static final String MARK_PAGE_BLOCK = "page_block";
private static final String MARK_PAGE_UPDATE_DATE = "page_update_date";
private static final String MARK_ADMIN_USER_LANGUAGE = "admin_user_language";
// Parameters
private static final String PARAMETER_IMAGE_CONTENT = "image_content";
......@@ -578,6 +579,7 @@ public class AdminPageJspBean extends AdminFeaturesPageJspBean
model.put( MARK_PAGE_THEMES_LIST, ThemesService.getPageThemes( getLocale( ) ) );
model.put( MARK_IMAGE_URL, getResourceImagePage( page, Integer.toString( page.getId( ) ) ) );
model.put( MARK_PAGE_UPDATE_DATE, DateUtil.getDateString( page.getDateUpdate( ), request.getLocale( ) ) );
model.put( MARK_ADMIN_USER_LANGUAGE, getUser( ).getLocale( ).getLanguage( ) );
int nIndexRow = 1;
StringBuilder strPageTemplatesRow = new StringBuilder( );
......
......@@ -41,6 +41,7 @@ public final class Markers
public static final String BASE_URL = "base_url";
public static final String VERSION = "version";
public static final String ENCODING = "encoding";
public static final String USER_CONTEXT_LANGUAGE = "user_context_language";
public static final String PAGE_PATH = "page_path";
public static final String PAGE_HEADER = "page_header";
public static final String PAGE_NAME = "page_name";
......
......@@ -149,32 +149,32 @@ public final class LocaleService
*/
public static Locale getContextUserLocale( HttpServletRequest request )
{
Locale locale = null;
// consider the current session locale
HttpSession session = request.getSession( false );
if ( session != null )
if ( request != null )
{
Locale userSessionLocale = (Locale) session.getAttribute( ATTRIBUTE_SELECTED_LOCALE );
if ( userSessionLocale != null )
HttpSession session = request.getSession( false );
if ( session != null )
{
locale = userSessionLocale;
Locale userSessionLocale = (Locale) session.getAttribute( ATTRIBUTE_SELECTED_LOCALE );
if ( userSessionLocale != null )
{
if ( isSupported( userSessionLocale ) )
{
return userSessionLocale;
}
}
}
}
if ( locale == null || !isSupported( locale ) )
// consider the browser language
Locale locale = new Locale( request.getLocale( ).getLanguage( ).substring( 0, 2 ) );
if ( isSupported( locale ) )
{
// consider the browser language
locale = new Locale( request.getLocale( ).getLanguage( ).substring( 0, 2 ) );
if ( !isSupported( locale ) )
{
// consider the server default
locale = getDefault( );
}
return locale;
}
return locale;
// otherwise consider the server default
return getDefault( );
}
/**
......
......@@ -60,7 +60,7 @@
</#if>
<@input type='text' name='manual_update_date' id='manual_update_date'value='${page_update_date!}' disabled=disabled />
</div>
<@getDatePickerBootstrap idField="manual_update_date" language='fr' />
<@getDatePickerBootstrap idField="manual_update_date" language=admin_user_language />
</@formGroup>
</@fieldSet>
</@boxBody>
......
......@@ -56,7 +56,7 @@
</#if>
<@input type='date' id='manual_update_date' name='manual_update_date' value='${page_update_date!}' disabled=disabled />
</@inputGroup>
<@getDatePickerBootstrap idField="manual_update_date" language='fr' />
<@getDatePickerBootstrap idField="manual_update_date" language=admin_user_language />
</@formGroup>
</@fieldSet>
<hr></hr>
......
<!DOCTYPE html>
<html lang="fr">
<html lang="${user_context_language}">
<head>
<base href="${base_url}">
<title>${favourite} - ${page_name}</title>
......
......@@ -4,7 +4,7 @@
<base href="${base_url}" />
<title>#i18n{portal.site.popup_send_resource.title}</title>
<meta http-equiv="Content-Type" content="text/html"/>
<meta http-equiv="Content-Language" content="fr"/>
<meta http-equiv="Content-Language" content="${user_context_language}"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le styles -->
<link href="css/bootstrap.min.css" rel="stylesheet"/>
......
<!DOCTYPE html>
<html lang="fr">
<html lang="${user_context_language}">
<head>
<base href="${base_url}"/>
<title>#i18n{portal.site.standalone_app.applicationsList.pageTitle}</title>
<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" >
<meta charset="UTF-8"/>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="Content-Language" content="fr"/>
<meta http-equiv="Content-Language" content="${user_context_language}"/>
<meta name="author" content=""/>
<meta name="copyright" content=""/>
<meta name="keywords" content=""/>
......
<!DOCTYPE html>
<html lang="fr">
<html lang="${user_context_language}">
<head>
<base href="${base_url}"/>
<title>${favourite} - ${page_name}</title>
<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" >
<meta charset="UTF-8"/>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="Content-Language" content="fr"/>
<meta http-equiv="Content-Language" content="${user_context_language}"/>
<meta name="author" content=""/>
<meta name="copyright" content=""/>
<meta name="keywords" content=""/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment