dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25210
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12438: Made login page locale selection persist through a cookie
------------------------------------------------------------
revno: 12438
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-10-05 16:04:38 +0200
message:
Made login page locale selection persist through a cookie
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18n.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/LocaleUtils.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18n.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18n.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18n.java 2013-10-05 14:04:38 +0000
@@ -35,11 +35,11 @@
* @author Pham Thi Thuy
* @author Nguyen Dang Quang
* @author Anders Gjendem
- * @version $Id: I18n.java 3252 2007-04-23 08:31:48Z andegje $
*/
public class I18n
{
- String ID = I18n.class.getName();
+ final String ID = I18n.class.getName();
+
private ResourceBundle globalResourceBundle;
private ResourceBundle specificResourceBundle;
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/LocaleUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/LocaleUtils.java 2013-10-04 15:05:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/LocaleUtils.java 2013-10-05 14:04:38 +0000
@@ -45,35 +45,9 @@
*/
public static Locale getLocale( String localeStr )
{
- if ( localeStr == null || localeStr.trim().isEmpty() )
- {
- return null;
- }
-
- String[] parts = localeStr.split( SEP );
-
- Locale thisLocale;
-
- if ( parts.length == 1 )
- {
- thisLocale = new Locale( parts[0] );
- }
- else if ( parts.length == 2 )
- {
- thisLocale = new Locale( parts[0], parts[1] );
- }
- else if ( parts.length == 3 )
- {
- thisLocale = new Locale( parts[0], parts[1], parts[2] );
- }
- else
- {
- return null;
- }
-
- return thisLocale;
+ return org.apache.commons.lang.LocaleUtils.toLocale( localeStr );
}
-
+
/**
* Createa a locale string based on the given language, country and varient.
*
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css 2013-10-04 17:06:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css 2013-10-05 14:04:38 +0000
@@ -184,6 +184,11 @@
border: 1px solid #333333;
}
+.noWrap
+{
+ white-space: nowrap;
+}
+
@font-face {
font-family: 'LiberationSansRegular';
src: url('../fonts/LiberationSans-Regular-webfont.eot');
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js 2013-10-04 17:06:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js 2013-10-05 14:04:38 +0000
@@ -1,3 +1,8 @@
+
+var login = {};
+
+login.localeCookie = "dhis2.locale";
+
$( document ).ready( function()
{
$( '#j_username' ).focus();
@@ -9,14 +14,21 @@
sessionStorage.removeItem( 'orgUnitSelected' );
} );
+
+ var locale = $.cookie( login.localeCookie );
+
+ if ( undefined !== locale )
+ {
+ login.changeLocale( locale );
+ $( '#localeSelect option[value="' + locale + '"]' ).attr( 'selected', 'selected' );
+ }
} );
-var login = {};
-
login.localeChanged = function()
{
var locale = $( '#localeSelect :selected' ).val();
- login.changeLocale( locale );
+ login.changeLocale( locale );
+ $.cookie( login.localeCookie, locale );
}
login.changeLocale = function( locale )
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm 2013-10-04 17:06:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm 2013-10-05 14:04:38 +0000
@@ -6,6 +6,7 @@
<meta name="keywords" content="DHIS 2">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
+ <script type="text/javascript" src="../javascripts/jQuery/jquery.cookie.js"></script>
<script type="text/javascript" src="login.js"></script>
<link type="text/css" rel="stylesheet" href="../css/widgets.css">
<link type="text/css" rel="stylesheet" href="../css/login.css">