=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/TranslateSystemSettingManager.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/TranslateSystemSettingManager.java 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/TranslateSystemSettingManager.java 2013-10-16 17:46:06 +0000 @@ -37,4 +37,6 @@ public interface TranslateSystemSettingManager { Map getTranslation_SystemAppearanceSetting( String localeStr ); + + Map getTranslationNoFallback_SystemAppearanceSetting( String localeStr ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2013-10-08 17:16:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2013-10-16 17:46:06 +0000 @@ -221,7 +221,7 @@ Translation translation = translationService.getTranslation( className, id, locale, key ); if ( value != null && !value.trim().isEmpty() ) - { + { if ( translation != null ) { translation.setValue( value ); @@ -256,6 +256,21 @@ return new HashMap(); } + public Map getTranslationsNoFallback( String className, int id ) + { + return getTranslationsNoFallback( className, id, getCurrentLocale() ); + } + + public Map getTranslationsNoFallback( String className, int id, Locale locale ) + { + if ( locale != null && className != null ) + { + return convertTranslations( translationService.getTranslationsNoFallback( className, id, locale ) ); + } + + return new HashMap(); + } + // ------------------------------------------------------------------------- // Locale // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nService.java 2013-10-01 16:44:42 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/I18nService.java 2013-10-16 17:46:06 +0000 @@ -64,11 +64,15 @@ // ------------------------------------------------------------------------- void updateTranslation( String className, int id, Locale thisLocale, Map translations ); - + Map getTranslations( String className, int id ); Map getTranslations( String className, int id, Locale locale ); + Map getTranslationsNoFallback( String className, int id ); + + Map getTranslationsNoFallback( String className, int id, Locale locale ); + // ------------------------------------------------------------------------- // Locale // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultTranslateSystemSettingManager.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultTranslateSystemSettingManager.java 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/setting/DefaultTranslateSystemSettingManager.java 2013-10-16 17:46:06 +0000 @@ -74,6 +74,20 @@ return translations; } + @Override + public Map getTranslationNoFallback_SystemAppearanceSetting( String localeStr ) + { + Map translations = new Hashtable(); + + // Add the key application data (with localeCode name) into translations map object + translations.put( KEY_APPLICATION_TITLE, systemSettingManager.getSystemSetting( KEY_APPLICATION_TITLE + localeStr, DEFAULT_APPLICATION_TITLE ).toString() ); + translations.put( KEY_APPLICATION_INTRO, systemSettingManager.getSystemSetting( KEY_APPLICATION_INTRO + localeStr, "" ).toString() ); + translations.put( KEY_APPLICATION_NOTIFICATION, systemSettingManager.getSystemSetting( KEY_APPLICATION_NOTIFICATION + localeStr, "" ).toString() ); + translations.put( KEY_APPLICATION_FOOTER, systemSettingManager.getSystemSetting( KEY_APPLICATION_FOOTER + localeStr, "" ).toString() ); + + return translations; + } + // ------------------------------------------------------------------------- // Support Method implementation // ------------------------------------------------------------------------- === removed file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/systemAppearanceSettingsString.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/systemAppearanceSettingsString.vm 2013-10-10 15:49:20 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/systemAppearanceSettingsString.vm 1970-01-01 00:00:00 +0000 @@ -1,6 +0,0 @@ -{ -"applicationTitle": "$!encoder.jsonEncode( $!translations.get( "applicationTitle" ) )", -"keyApplicationIntro": "$!encoder.jsonEncode( $translations.get( "keyApplicationIntro" ) )", -"keyApplicationNotification": "$!encoder.jsonEncode( $translations.get( "keyApplicationNotification" ) )", -"keyApplicationFooter": "$!encoder.jsonEncode( $translations.get( "keyApplicationFooter" ) )" -} === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/GetTranslationsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/GetTranslationsAction.java 2013-10-01 16:44:42 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/GetTranslationsAction.java 2013-10-16 17:46:06 +0000 @@ -94,7 +94,7 @@ { Locale locale = LocaleUtils.getLocale( loc ); - translations = i18nService.getTranslations( className, id, locale ); + translations = i18nService.getTranslationsNoFallback( className, id, locale ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/I18nAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/I18nAction.java 2013-10-01 16:44:42 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/I18nAction.java 2013-10-16 17:46:06 +0000 @@ -169,7 +169,7 @@ availableLocales = i18nService.getAvailableLocales(); - translations = i18nService.getTranslations( className, objectId ); + translations = i18nService.getTranslationsNoFallback( className, objectId ); IdentifiableObject object = identifiableObjectManager.getObject( objectId, className ); === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/TranslateAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/TranslateAction.java 2013-10-01 16:44:42 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/TranslateAction.java 2013-10-16 17:46:06 +0000 @@ -157,8 +157,8 @@ for ( String propertyName : propertyNames ) { String[] translation = request.getParameterValues( propertyName ); - - if ( translation != null && translation.length > 0 && translation[0] != null && !translation[0].trim().isEmpty() ) + + if ( translation != null && translation.length > 0 ) { translations.put( propertyName, translation[0] ); } === removed directory 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/system' === removed directory 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/system/action' === removed file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/system/action/GetAppearanceSettingsStringAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/system/action/GetAppearanceSettingsStringAction.java 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/system/action/GetAppearanceSettingsStringAction.java 1970-01-01 00:00:00 +0000 @@ -1,87 +0,0 @@ -package org.hisp.dhis.settings.system.action; - -/* - * 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 java.util.Hashtable; -import java.util.Map; - -import org.hisp.dhis.setting.TranslateSystemSettingManager; - -import com.opensymphony.xwork2.Action; - -/** - * @author James Chang - */ -public class GetAppearanceSettingsStringAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private TranslateSystemSettingManager translateSystemSettingManager; - - public void setTranslateSystemSettingManager( TranslateSystemSettingManager translateSystemSettingManager ) - { - this.translateSystemSettingManager = translateSystemSettingManager; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private String localeCode; - - public void setLocaleCode( String localeCode ) - { - this.localeCode = localeCode; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private Map translations = new Hashtable(); - - public Map getTranslations() - { - return translations; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - translations = translateSystemSettingManager.getTranslation_SystemAppearanceSetting( localeCode ); - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2013-10-16 17:46:06 +0000 @@ -595,14 +595,6 @@ - - - - - - === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2013-10-16 17:46:06 +0000 @@ -467,11 +467,6 @@ plainTextError - - - /dhis-web-commons/settings/systemAppearanceSettingsString.vm - - === 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-16 17:46:06 +0000 @@ -0,0 +1,87 @@ +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 java.util.Hashtable; +import java.util.Map; + +import org.hisp.dhis.setting.TranslateSystemSettingManager; + +import com.opensymphony.xwork2.Action; + +/** + * @author James Chang + */ +public class GetAppearanceSettingsStringAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private TranslateSystemSettingManager translateSystemSettingManager; + + public void setTranslateSystemSettingManager( TranslateSystemSettingManager translateSystemSettingManager ) + { + this.translateSystemSettingManager = translateSystemSettingManager; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String localeCode; + + public void setLocaleCode( String localeCode ) + { + this.localeCode = localeCode; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Map translations = new Hashtable(); + + public Map getTranslations() + { + return translations; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + translations = translateSystemSettingManager.getTranslationNoFallback_SystemAppearanceSetting( localeCode ); + + return SUCCESS; + } +} === 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 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2013-10-16 17:46:06 +0000 @@ -41,6 +41,12 @@ + + + + === 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 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml 2013-10-16 17:46:06 +0000 @@ -47,6 +47,10 @@ F_SYSTEM_SETTING + + /dhis-web-maintenance-settings/systemAppearanceSettingsString.vm + + === modified 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 2013-10-10 12:00:38 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/systemAppearanceSettings.js 2013-10-16 17:46:06 +0000 @@ -1,7 +1,7 @@ function changeLocale() { - $.get( '../dhis-web-commons-ajax/systemAppearanceSettingsString.action?localeCode=' + $( '#localeSelect' ).val(), function( json ) { + $.get( 'systemAppearanceSettingsString.action?localeCode=' + $( '#localeSelect' ).val(), function( json ) { $( '#applicationTitle' ).val( json.applicationTitle ); $( '#applicationIntro' ).val( json.keyApplicationIntro ); $( '#applicationNotification' ).val( json.keyApplicationNotification ); === 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-16 17:46:06 +0000 @@ -0,0 +1,6 @@ +{ +"applicationTitle": "$!encoder.jsonEncode( $!translations.get( "applicationTitle" ) )", +"keyApplicationIntro": "$!encoder.jsonEncode( $translations.get( "keyApplicationIntro" ) )", +"keyApplicationNotification": "$!encoder.jsonEncode( $translations.get( "keyApplicationNotification" ) )", +"keyApplicationFooter": "$!encoder.jsonEncode( $translations.get( "keyApplicationFooter" ) )" +}