dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25321
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12529: System Appearance Setting Locale translation add.
------------------------------------------------------------
revno: 12529
committer: James Chang <jamesbchang@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-09 20:47:12 +0700
message:
System Appearance Setting Locale translation add.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsStringAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/systemAppearanceSettings.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettingsString.vm
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetAppearanceSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettings.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-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsAction.java 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsAction.java 2013-10-09 13:47:12 +0000
@@ -29,8 +29,10 @@
*/
import java.util.List;
+import java.util.Locale;
import java.util.SortedMap;
+import org.hisp.dhis.i18n.locale.LocaleManager;
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.setting.StyleManager;
import org.hisp.dhis.system.util.Filter;
@@ -74,6 +76,13 @@
this.styleManager = styleManager;
}
+ private LocaleManager localeManager;
+
+ public void setLocaleManager( LocaleManager localeManager )
+ {
+ this.localeManager = localeManager;
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -106,12 +115,37 @@
return currentStyle;
}
+ private List<Locale> availableLocales;
+
+ public List<Locale> getAvailableLocales()
+ {
+ return availableLocales;
+ }
+
+// private Locale currentLocale;
+//
+// public Locale getCurrentLocale()
+// {
+// return currentLocale;
+// }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute()
{
+ // ---------------------------------------------------------------------
+ // Get available UI locales
+ // ---------------------------------------------------------------------
+ availableLocales = localeManager.getAvailableLocales();
+
+ //currentLocale = localeManager.getCurrentLocale();
+
+ // ---------------------------------------------------------------------
+ // Others
+ // ---------------------------------------------------------------------
+
styles = styleManager.getStyles();
currentStyle = styleManager.getSystemStyle();
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsStringAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsStringAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetAppearanceSettingsStringAction.java 2013-10-09 13:47:12 +0000
@@ -0,0 +1,97 @@
+package org.hisp.dhis.settings.action.system;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_APPLICATION_TITLE;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_FOOTER;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_INTRO;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_NOTIFICATION;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_APPLICATION_TITLE;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.hisp.dhis.setting.SystemSettingManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author James Chang
+ */
+public class GetAppearanceSettingsStringAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SystemSettingManager systemSettingManager;
+
+ public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+ {
+ this.systemSettingManager = systemSettingManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private String localeCode;
+
+ public void setLocaleCode( String localeCode )
+ {
+ this.localeCode = localeCode;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Map<String, Object> translations = new Hashtable<String, Object>();
+
+ public Map<String, Object> getTranslations()
+ {
+ return translations;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ // Add the key application data (with localeCode name) into translations map object
+ translations.put( KEY_APPLICATION_TITLE, systemSettingManager.getSystemSetting( KEY_APPLICATION_TITLE + localeCode, DEFAULT_APPLICATION_TITLE ) );
+ translations.put( KEY_APPLICATION_INTRO, systemSettingManager.getSystemSetting( KEY_APPLICATION_INTRO + localeCode, "" ) );
+ translations.put( KEY_APPLICATION_NOTIFICATION, systemSettingManager.getSystemSetting( KEY_APPLICATION_NOTIFICATION + localeCode, "" ) );
+ translations.put( KEY_APPLICATION_FOOTER, systemSettingManager.getSystemSetting( KEY_APPLICATION_FOOTER + localeCode, "" ) );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetAppearanceSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetAppearanceSettingsAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetAppearanceSettingsAction.java 2013-10-09 13:47:12 +0000
@@ -133,7 +133,14 @@
{
this.i18n = i18n;
}
+
+ private String localeSelect;
+ public void setLocaleSelect( String localeSelect )
+ {
+ this.localeSelect = localeSelect;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -154,11 +161,11 @@
{
startModule = null;
}
-
- systemSettingManager.saveSystemSetting( KEY_APPLICATION_TITLE, applicationTitle );
- systemSettingManager.saveSystemSetting( KEY_APPLICATION_INTRO, applicationIntro );
- systemSettingManager.saveSystemSetting( KEY_APPLICATION_NOTIFICATION, applicationNotification );
- systemSettingManager.saveSystemSetting( KEY_APPLICATION_FOOTER, applicationFooter );
+
+ systemSettingManager.saveSystemSetting( KEY_APPLICATION_TITLE + localeSelect, applicationTitle );
+ systemSettingManager.saveSystemSetting( KEY_APPLICATION_INTRO + localeSelect, applicationIntro );
+ systemSettingManager.saveSystemSetting( KEY_APPLICATION_NOTIFICATION + localeSelect, applicationNotification );
+ systemSettingManager.saveSystemSetting( KEY_APPLICATION_FOOTER + localeSelect, applicationFooter );
systemSettingManager.saveSystemSetting( KEY_FLAG, flag );
systemSettingManager.saveSystemSetting( KEY_START_MODULE, startModule );
styleManager.setSystemStyle( currentStyle );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2012-12-14 13:46:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2013-10-09 13:47:12 +0000
@@ -31,6 +31,7 @@
<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
<property name="moduleManager" ref="org.hisp.dhis.webportal.module.ModuleManager" />
<property name="styleManager" ref="org.hisp.dhis.setting.StyleManager" />
+ <property name="localeManager" ref="org.hisp.dhis.i18n.locale.LocaleManager" />
</bean>
<bean id="org.hisp.dhis.settings.action.system.SetAppearanceSettingsAction"
@@ -40,6 +41,13 @@
<property name="styleManager" ref="org.hisp.dhis.setting.StyleManager" />
</bean>
+ <bean id="org.hisp.dhis.settings.action.system.GetAppearanceSettingsStringAction"
+ class="org.hisp.dhis.settings.action.system.GetAppearanceSettingsStringAction"
+ scope="prototype">
+ <property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
+ </bean>
+
+
<bean id="org.hisp.dhis.settings.action.system.GetSMTPSettingsAction"
class="org.hisp.dhis.settings.action.system.GetSMTPSettingsAction"
scope="prototype">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml 2012-10-31 05:41:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml 2013-10-09 13:47:12 +0000
@@ -36,6 +36,7 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-settings/systemAppearanceSettings.vm</param>
<param name="menu">/dhis-web-maintenance-settings/settingsMenu.vm</param>
+ <param name="javascripts">/dhis-web-maintenance-settings/javascripts/systemAppearanceSettings.js</param>
<param name="requiredAuthorities">F_SYSTEM_SETTING</param>
</action>
@@ -46,6 +47,10 @@
<param name="requiredAuthorities">F_SYSTEM_SETTING</param>
</action>
+ <action name="systemAppearanceSettingsString" class="org.hisp.dhis.settings.action.system.GetAppearanceSettingsStringAction">
+ <result name="success" type="velocity-json">/dhis-web-maintenance-settings/systemAppearanceSettingsString.vm</result>
+ </action>
+
<!-- Email settings -->
<action name="systemEmailSettings" class="org.hisp.dhis.settings.action.system.GetSMTPSettingsAction">
=== added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts'
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/systemAppearanceSettings.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/systemAppearanceSettings.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/systemAppearanceSettings.js 2013-10-09 13:47:12 +0000
@@ -0,0 +1,10 @@
+
+function changeLocale()
+{
+ $.get( 'systemAppearanceSettingsString.action?localeCode=' + $( '#localeSelect' ).val(), function( json ) {
+ $( '#applicationTitle' ).val( json.applicationTitle );
+ $( '#applicationIntro' ).val( json.keyApplicationIntro );
+ $( '#applicationNotification' ).val( json.keyApplicationNotification );
+ $( '#applicationFooter' ).val( json.keyApplicationFooter );
+ } );
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettings.vm 2013-10-01 16:44:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettings.vm 2013-10-09 13:47:12 +0000
@@ -8,7 +8,8 @@
applicationFooter: getFieldValue( 'applicationFooter' ),
currentStyle: getFieldValue( 'currentStyle' ),
flag: getFieldValue( 'flag' ),
- startModule: getFieldValue( 'startModule' )
+ startModule: getFieldValue( 'startModule' ),
+ localeSelect: getFieldValue( 'localeSelect' )
}, function( json ) {
if ( json.response == "success" ) {
setHeaderDelayMessage( json.message );
@@ -18,6 +19,17 @@
});
</script>
+<div style="width:370px;">
+ <div style="float:right;">
+ <select id="localeSelect" name="localeSelect" onchange="changeLocale()" style="width:auto !important;">
+ <option value="">[ Select locale ]</option>
+ #foreach( $locale in $availableLocales )
+ <option value="$locale.toString()">$locale.getDisplayName()</option>
+ #end
+ </select>
+ </div>
+</div>
+
<h3>$i18n.getString( "appearance_settings" ) #openHelp( "systemAppearanceSettings" )</h3>
<div class="settingLabel">$i18n.getString( "application_title" )</div>
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettingsString.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettingsString.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemAppearanceSettingsString.vm 2013-10-09 13:47:12 +0000
@@ -0,0 +1,15 @@
+{
+"applicationTitle": "$!encoder.htmlEncode( $!translations.get( "applicationTitle" ) )",
+
+#set($strKeyApplicationIntro = $!translations.get( "keyApplicationIntro" ) )
+#set($strKeyApplicationIntro = $strKeyApplicationIntro.replaceAll( "'", ''' ) )
+"keyApplicationIntro": "$!encoder.jsEncode( $strKeyApplicationIntro )",
+
+#set($strKeyApplicationNotification = $!translations.get( "keyApplicationNotification" ) )
+#set($strKeyApplicationNotification = $strKeyApplicationNotification.replaceAll( "'", ''' ) )
+"keyApplicationNotification": "$!encoder.jsEncode( $strKeyApplicationNotification )",
+
+#set($strKeyApplicationFooter = $!translations.get( "keyApplicationFooter" ) )
+#set($strKeyApplicationFooter = $strKeyApplicationFooter.replaceAll("'", ''') )
+"keyApplicationFooter": "$!encoder.jsEncode( $strKeyApplicationFooter )"
+}