dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25208
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12436: Impl support for translation of login page static text
------------------------------------------------------------
revno: 12436
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-10-04 19:06:16 +0200
message:
Impl support for translation of login page static text
modified:
dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/DefaultI18nManager.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
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/GetStringsFromLocaleAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_es.properties
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_fr.properties
--
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-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/DefaultI18nManager.java'
--- dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/DefaultI18nManager.java 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/DefaultI18nManager.java 2013-10-04 17:06:16 +0000
@@ -76,7 +76,7 @@
public I18n getI18n( Class<?> clazz, Locale locale )
throws I18nManagerException
{
- return new I18n( getGlobalResourceBundle(), getSpecificResourceBundle( clazz.getName() ) );
+ return new I18n( getGlobalResourceBundle( locale ), getSpecificResourceBundle( clazz.getName(), locale ) );
}
@Override
@@ -103,9 +103,15 @@
private ResourceBundle getGlobalResourceBundle()
throws I18nManagerException
{
+ return getGlobalResourceBundle( getCurrentLocale() );
+ }
+
+ private ResourceBundle getGlobalResourceBundle( Locale locale )
+ throws I18nManagerException
+ {
try
{
- return resourceBundleManager.getGlobalResourceBundle( getCurrentLocale() );
+ return resourceBundleManager.getGlobalResourceBundle( locale );
}
catch ( ResourceBundleManagerException e )
{
@@ -117,6 +123,11 @@
{
return resourceBundleManager.getSpecificResourceBundle( clazzName, getCurrentLocale() );
}
+
+ private ResourceBundle getSpecificResourceBundle( String clazzName, Locale locale )
+ {
+ return resourceBundleManager.getSpecificResourceBundle( clazzName, locale );
+ }
private Locale getCurrentLocale()
{
=== 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-01 16:44:42 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css 2013-10-04 17:06:16 +0000
@@ -135,6 +135,11 @@
color: #6b90b8;
width: 100%;
}
+
+#localeSelect
+{
+ width: 160px;
+}
.greenButtonLink
{
=== 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 16:25:27 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.js 2013-10-04 17:06:16 +0000
@@ -12,3 +12,22 @@
} );
var login = {};
+
+login.localeChanged = function()
+{
+ var locale = $( '#localeSelect :selected' ).val();
+ login.changeLocale( locale );
+}
+
+login.changeLocale = function( locale )
+{
+ $.get( 'loginStrings.action?loc=' + locale, function( json ) {
+ $( '#createAccountButton' ).html( json.create_an_account );
+ $( '#usernameLabel' ).html( json.login_username );
+ $( '#passwordLabel' ).html( json.login_password );
+ $( '#forgotPasswordLink' ).html( json.forgot_password );
+ $( '#createAccountLink' ).html( json.create_an_account );
+ $( '#loginMessage' ).html( json.wrong_username_or_password );
+ $( '#poweredByLabel' ).html( json.powered_by );
+ } );
+}
\ No newline at end of file
=== 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 16:25:27 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.vm 2013-10-04 17:06:16 +0000
@@ -26,7 +26,7 @@
</div>
#if ( $keyConfig.selfRegistrationAllowed() )
<div id="accountArea">
- <a id="createAccountButton" class="greenButtonLink" href="account.action">$i18n.getString( "create_an_account" )</a>
+ <a id="createAccountButton" class="greenButtonLink" href="account.action">Create an account</a>
</div>
#end
<div id="loginField">
@@ -35,11 +35,11 @@
<form id="loginForm" action="../../dhis-web-commons-security/login.action" method="post">
<table>
<tr>
- <td><label id="usernameLabel" for="j_username">$i18n.getString( "login_username" )</label></td>
+ <td><label id="usernameLabel" for="j_username">Username</label></td>
<td><input type="text" id="j_username" name="j_username"></td>
</tr>
<tr>
- <td><label id="passwordLabel" for="j_password">$i18n.getString( "login_password" )</label></td>
+ <td><label id="passwordLabel" for="j_password">Password</label></td>
<td><input type="password" id="j_password" name="j_password" autocomplete="off"></td>
</tr>
<tr>
@@ -54,10 +54,10 @@
<td style="padding-top:8px">
<span id="loginFormFooter">
#if( $keyAccountRecovery )
- <a id="forgotPasswordLink" href="recovery.action">$i18n.getString( "forgot_password" )</a>
+ <a id="forgotPasswordLink" href="recovery.action">Forgot password?</a>
#end
#if( $keyConfig.selfRegistrationAllowed() )
- <a id="createAccountLink" href="account.action">$i18n.getString( "create_an_account" )</a>
+ <a id="createAccountLink" href="account.action">Create an account</a>
#end
</span>
</td>
@@ -65,16 +65,24 @@
</table>
</form>
#if( $failed == true )
- <span id="loginMessage">$i18n.getString( "wrong_username_or_password" )</span>
+ <span id="loginMessage">Wrong username or password</span>
#end
#if ( $keyApplicationNotification )
<div id="notificationArea">$!{keyApplicationNotification}</div>
#end
</div>
<div id="footerArea">
- <span id="poweredByLabel">$i18n.getString( "powered_by" )</span>
+ <span id="poweredByLabel">Powered by</span>
<a href="http://www.dhis2.org">DHIS 2</a>
- $!{keyApplicationFooter}
+ $!{keyApplicationFooter}
+
+ <select id="localeSelect" onchange="login.localeChanged()">
+ <option value="">[ Change language ]</option>
+ #foreach( $locale in $availableLocales )
+ <option value="${locale.language}">${locale.displayLanguage}</option>
+ #end
+ </select>
+
</div>
</body>
</html>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginStrings.vm 2013-10-04 17:06:16 +0000
@@ -1,7 +1,7 @@
{
"create_an_account": "$!i18nObject.getString( "create_an_account" )",
+"login_username": "$!i18nObject.getString( "login_username" )",
"login_password": "$!i18nObject.getString( "login_password" )",
-"login_username": "$!i18nObject.getString( "login_username" )",
"forgot_password": "$!i18nObject.getString( "forgot_password" )",
"create_an_account": "$!i18nObject.getString( "create_an_account" )",
"wrong_username_or_password": "$!i18nObject.getString( "wrong_username_or_password" )",
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/GetStringsFromLocaleAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/GetStringsFromLocaleAction.java 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/GetStringsFromLocaleAction.java 2013-10-04 17:06:16 +0000
@@ -31,6 +31,7 @@
import com.opensymphony.xwork2.Action;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nManager;
+import org.hisp.dhis.system.util.LocaleUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Locale;
@@ -44,18 +45,11 @@
@Autowired
private I18nManager manager;
- private String language;
-
- public void setLanguage( String language )
- {
- this.language = language;
- }
-
- private String country;
-
- public void setCountry( String country )
- {
- this.country = country;
+ private String loc;
+
+ public void setLoc( String loc )
+ {
+ this.loc = loc;
}
private I18n i18nObject;
@@ -72,26 +66,13 @@
public String execute()
throws Exception
{
- Locale locale;
-
- if ( language != null )
- {
- if ( country != null )
- {
- locale = new Locale( language, country );
- }
- else
- {
- locale = new Locale( language );
- }
- }
- else
- {
- locale = null;
- }
-
- i18nObject = manager.getI18n( this.getClass(), locale );
-
+ Locale locale = LocaleUtils.getLocale( loc );
+
+ if ( loc != null )
+ {
+ i18nObject = manager.getI18n( this.getClass(), locale );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_es.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_es.properties 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_es.properties 2013-10-04 17:06:16 +0000
@@ -605,3 +605,11 @@
algeria=Algeria
global_fund=El Fondo Mundial
timor_leste=Timor Oriental
+create_an_account=Crear una cuenta
+login_password=Contrasena
+login_username=Nombre de usuario
+forgot_password=�Olvido su contrasena?
+wrong_username_or_password=Nombre de usuario o contrasena incorrecta
+powered_by=Impulsado por
+login=Login
+clear=Clarificar
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_fr.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_fr.properties 2013-10-04 16:25:27 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_fr.properties 2013-10-04 17:06:16 +0000
@@ -610,11 +610,11 @@
nationality=Nationalit\u00E9
update_access_denied_message=Vous n'avez pas de droit de mise \u00E0 jour sur cet objet
please_enter_at_least_n_words=Veuillez saisir au moins {0} mots.
-create_an_account=Cr� un compte
+create_an_account=Cr\u00E9er un compte
login_password=Mot de passe
login_username=Identifiant
-forgot_password=Mot de passe oubli�+forgot_password=Mot de passe oublie?
wrong_username_or_password=Identifiant ou mot de passe incorrect
-powered_by=Propuls�ar
+powered_by=Propulse par
login=Entrer
clear=Clair
\ No newline at end of file