taylor 2002/11/14 12:30:24
Modified: build build.xml
webapp/WEB-INF/conf TurbineResources.properties
portlets.xreg
xdocs code-standards.xml
Added: src/java/org/apache/jetspeed/portal/portlets/language
ChangeLanguagePortlet.java ConstructorHtml.java
src/java/org/apache/jetspeed/services/customlocalization
CustomLocalization.java
CustomLocalizationService.java
CustomLocalizationTool.java
JetspeedLocalizationService.java
webapp/images ic-de.gif ic-en.gif ic-es.gif ic-fr.gif
ic-it.gif ic_ja.gif
Log:
Change Language Portlet, JetspeedLocalizationService contributed by Massimiliano
Dessi [[EMAIL PROTECTED]]
Its not working yet, but hope to work with Massimiliano to clean it up soon
Revision Changes Path
1.169 +0 -26 jakarta-jetspeed/build/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/build/build.xml,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- build.xml 14 Nov 2002 18:04:32 -0000 1.168
+++ build.xml 14 Nov 2002 20:30:23 -0000 1.169
@@ -1219,32 +1219,6 @@
<!-- =================================================================== -->
- <!-- Run the client JUnit test cases (non-cactus) -->
- <!-- =================================================================== -->
- <target name="t" depends="compile"
- description="General unit tests">
-
- <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
-
- <classpath>
- <pathelement location="${build.dest.dir}"/>
- <path refid="classpath"/>
- <pathelement location="${junit.jar}"/>
- <pathelement location="${hsql.jar}"/>
- </classpath>
-
- <formatter type="plain" usefile="false"/>
-
- <!-- JUnit unit tests -->
- <test name="org.apache.jetspeed.cache.TestFileCache"/>
-<!--
- <test
name="org.apache.jetspeed.services.registry.TestRegistryPersistence"/>
--->
-
- </junit>
- </target>
-
- <!-- =================================================================== -->
<!-- Include the usage target and the test targets for the different -->
<!-- servlet engine -->
<!-- =================================================================== -->
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/language/ChangeLanguagePortlet.java
Index: ChangeLanguagePortlet.java
===================================================================
package org.apache.jetspeed.portal.portlets.language;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Dess� Massimiliano
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* version 1.0 10-2002
* jdk 1.4.1
*/
import org.apache.jetspeed.portal.portlets.AbstractPortlet;
import org.apache.jetspeed.util.template.BaseJetspeedLink;
import org.apache.jetspeed.om.security.*;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.velocity.TurbineVelocity;
import org.apache.ecs.ConcreteElement;
import org.apache.ecs.StringElement;
import org.apache.velocity.context.Context;
import javax.servlet.http.*;
import java.util.Locale;
import java.util.Properties;
import java.io.*;
public class ChangeLanguagePortlet extends AbstractPortlet {
private static String REFRESH = "<META HTTP-EQUIV=\"REFRESH\" CONTENT=0,01 >";
private StringBuffer text = new StringBuffer();
private String refresh = "";
public ConcreteElement getContent(RunData data) {
String html = "";
String userLanguage = "";
HttpSession httpSession = data.getRequest().getSession();
if (data.getUser().getPerm("language") != null)
{
userLanguage = (String)data.getUser().getPerm("language");
}
String requestLanguage = data.getRequest().getParameter("cL");
ConstructorHtml constructor = new ConstructorHtml();
html = constructor.getHtml(data,userLanguage,requestLanguage);
if ( requestLanguage != null){
if (!requestLanguage.equals(userLanguage)) {
data.getUser().setPerm("language", requestLanguage);
html = this.REFRESH + html;
}
}
return (new StringElement(html.toString()));
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/language/ConstructorHtml.java
Index: ConstructorHtml.java
===================================================================
package org.apache.jetspeed.portal.portlets.language;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Dess� Massimiliano
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* version 1.0 10-2002
* jdk 1.4.1
*/
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.velocity.TurbineVelocity;
import org.apache.velocity.context.Context;
import org.apache.jetspeed.util.template.BaseJetspeedLink;
public class ConstructorHtml {
public ConstructorHtml(){
}
public String getHtml(RunData data,String language, String requestLanguage){
return constructorContent(data , language, requestLanguage);
}
private String constructorContent(RunData data, String linguaAttuale, String
linguaRichiesta) {
String linkCurrentPage = this.createLinkCurrentPage(data);
String html = "<body bgcolor=\"#FFFFFF\" text=\"#000000\">" +
"<a href=" + linkCurrentPage + "?cL=it>IT</a> " +
"<a href=" + linkCurrentPage + "?cL=en>EN</a> " +
"<a href=" + linkCurrentPage + "?cL=es>ES</a> " +
"<a href=" + linkCurrentPage + "?cL=de>DE</a> " +
"<a href=" + linkCurrentPage + "?cL=fr>FR</a> " +
"<a href=" + linkCurrentPage + "?cL=no>NO</a> " +
"<a href=" + linkCurrentPage + "?cL=ja>JA</a> " +
"</body></html>";
/* to enable icon flag uncomment this put the gif in jetspeed\images\ and
comment the previous*/
/*String html="<body bgcolor=\"#FFFFFF\" text=\"#000000\">"+
"<a href=" + linkCurrentPage + "?cL=en><img
src=\"images/ic-en.gif\" width=\"38\" height=\"38\" border=\"0\"></a> "+
"<a href=" + linkCurrentPage + "?cL=it><img
src=\"images/ic-it.gif\" width=\"38\" height=\"38\" border=\"0\"></a> "+
"<a href=" + linkCurrentPage + "?cL=fr><img
src=\"images/ic-fr.gif\" width=\"38\" height=\"38\" border=\"0\"></a> "+
"<a href=" + linkCurrentPage + "?cL=de><img
src=\"images/ic-de.gif\" width=\"38\" height=\"38\" border=\"0\"></a> "+
"<a href=" + linkCurrentPage + "?cL=es><img
src=\"images/ic-es.gif\" width=\"38\" height=\"38\" border=\"0\"></a> "+
"<a href=" + linkCurrentPage + "?cL=ja><img
src=\"images/ic_ja.gif\" width=\"38\" height=\"38\" border=\"0\"></a> "+
"</body></html>";*/
return html;
}
private String createLinkCurrentPage(RunData data) {
Context context = TurbineVelocity.getContext(data);
Object jslink = context.get("jslink");
String idPane = data.getParameters().getString("js_pane");
String linkPage = ((BaseJetspeedLink) jslink).getPaneById("Page").toString();
int lenght = linkPage.length();
String linkCurrentPage = linkPage.substring(0, lenght - 4) + idPane;
data.setRedirectURI(linkCurrentPage);
return linkCurrentPage;
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/CustomLocalization.java
Index: CustomLocalization.java
===================================================================
package org.apache.jetspeed.services.customlocalization;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Dess� Massimiliano
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* version 1.0 10-2002
* jdk 1.4.1
*/
import java.util.*;
import org.apache.turbine.services.*;
import org.apache.turbine.util.*;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.localization.Localization;
public abstract class CustomLocalization {
public CustomLocalization(){}
public static String getString(String bundleName, Locale locale, String key)
{
return getService().getString(bundleName, locale, key);
}
public static String getString(String key, RunData data)
{
return getService().getString(null, getLocale(data), key);
}
public static ResourceBundle getBundle( RunData data )
{
return getService().getBundle(data);
}
public static Locale getLocale(RunData data)
{
return getService().getLocale(data);
}
public static String getDefaultBundleName()
{
return getService().getDefaultBundleName();
}
protected static final CustomLocalizationService getService()
{
return (CustomLocalizationService)
TurbineServices.getInstance().getService(CustomLocalizationService.SERVICE_NAME);
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationService.java
Index: CustomLocalizationService.java
===================================================================
package org.apache.jetspeed.services.customlocalization;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Dess� Massimiliano
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* version 1.0 10-2002
* jdk 1.4.1
*/
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import org.apache.turbine.services.Service;
import org.apache.turbine.util.RunData;
public interface CustomLocalizationService extends Service
{
public abstract String getDefaultBundleName();
public abstract ResourceBundle getBundle(RunData data);
public abstract ResourceBundle getBundle(String s, RunData data);
public abstract Locale getLocale(RunData data);
public abstract String getString(String s, Locale locale, String s1);
public static final String SERVICE_NAME = "LocalizationService";
public static final String ACCEPT_LANGUAGE = "accept-Language";
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/CustomLocalizationTool.java
Index: CustomLocalizationTool.java
===================================================================
package org.apache.jetspeed.services.customlocalization;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Dess� Massimiliano
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* version 1.0 10-2002
* jdk 1.4.1
*/
import java.io.PrintStream;
import java.util.*;
import org.apache.turbine.services.pull.ApplicationTool;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
public class CustomLocalizationTool implements ApplicationTool
{
public CustomLocalizationTool()
{
refresh();
}
public String get(String key)
{
try
{
String s = CustomLocalization.getString(getBundleName(null),
getLocale(), key);
return s;
}
catch(MissingResourceException noKey)
{
Log.error(noKey);
}
return null;
}
public Locale getLocale()
{
return locale;
}
protected String getBundleName(Object data)
{
return CustomLocalization.getDefaultBundleName();
}
public final void init(Object data)
{
if(data instanceof RunData)
{
locale = CustomLocalization.getLocale((RunData)data);
bundleName = getBundleName(data);
}
}
public void refresh()
{
locale = null;
bundle = null;
bundleName = null;
}
protected Locale locale;
private ResourceBundle bundle;
private String bundleName;
boolean debug;
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/customlocalization/JetspeedLocalizationService.java
Index: JetspeedLocalizationService.java
===================================================================
package org.apache.jetspeed.services.customlocalization;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author Dess� Massimiliano
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* [EMAIL PROTECTED]
* version 1.0 10-2002
* jdk 1.4.1
*/
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.turbine.services.TurbineBaseService;
import org.apache.turbine.services.localization.TurbineLocalizationService;
import org.apache.turbine.services.InitializationException;
import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.util.*;
import org.apache.jetspeed.om.security.JetspeedUser;
public class JetspeedLocalizationService extends TurbineLocalizationService
implements CustomLocalizationService
{
public JetspeedLocalizationService()
{
super();
}
public void init()throws InitializationException
{
super.init();
}
protected void initBundleNames(String ignored[])
{
bundleNames = TurbineResources.getStringArray("locale.default.bundles");
String name = TurbineResources.getString("locale.default.bundle");
if(name != null && name.length() > 0)
if(bundleNames == null || bundleNames.length <= 0)
{
bundleNames = (new String[] {name});
} else
{
String array[] = new String[bundleNames.length + 1];
array[0] = name;
System.arraycopy(bundleNames, 0, array, 1, bundleNames.length);
bundleNames = array;
}
if(bundleNames == null)
bundleNames = new String[0];
}
public String getDefaultBundleName()
{
return bundleNames.length > 0 ? bundleNames[0] : "";
}
public ResourceBundle getBundle()
{
return super.getBundle();
}
public ResourceBundle getBundle(String bundleName)
{
return super.getBundle(bundleName);
}
public ResourceBundle getBundle(String bundleName, String languageHeader)
{
return super.getBundle(bundleName,languageHeader);
}
public ResourceBundle getBundle(RunData data)
{
return super.getBundle(data);
}
public ResourceBundle getBundle(String bundleName, RunData data)
{
return super.getBundle(bundleName,data);
}
public ResourceBundle getBundle(String bundleName, Locale locale)
{
return super.getBundle(bundleName,locale);
}
public void setBundle(String defaultBundle)
{
super.setBundle(defaultBundle);
}
public final Locale getLocale(RunData data)
{
String linguaggio=data.getLocale().getLanguage();
JetspeedUser user = (JetspeedUser)data.getUser();
if (user == null)
{
return
getLocale(data.getRequest().getHeader(CustomLocalizationService.ACCEPT_LANGUAGE));
}
else
{
String lang="null";
try
{
if (user.getPerm("language")==null)
{
return
getLocale(data.getRequest().getHeader(CustomLocalizationService.ACCEPT_LANGUAGE));
}
else
{
/* for jdk 1.3.1
lang = user.getPerm("language").toString();
int underscore=lang.indexOf("_");
String paese=lang.substring(0,2);
String stato=lang.substring(underscore+1);
Locale locale = new Locale(paese,stato);
return locale;
* */
/* for jdk 1.4.1 */
lang = user.getPerm("language").toString();
Locale locale = new Locale(lang);
return locale;
}
}
catch (Exception use)
{
return
getLocale(data.getRequest().getHeader(CustomLocalizationService.ACCEPT_LANGUAGE));
}
}
}
public Locale getLocale(String header)
{
return super.getLocale(header);
}
public String getString(String bundleName, Locale locale, String key)
{
return super.getString(bundleName,locale,key);
}
private Hashtable bundles;
private String bundleNames[];
private Locale defaultLocale;
private String defaultLanguage;
private String defaultCountry;
}
1.63 +4 -2 jakarta-jetspeed/webapp/WEB-INF/conf/TurbineResources.properties
Index: TurbineResources.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/TurbineResources.properties,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- TurbineResources.properties 14 Nov 2002 17:06:55 -0000 1.62
+++ TurbineResources.properties 14 Nov 2002 20:30:24 -0000 1.63
@@ -364,7 +364,8 @@
services.RunDataService.classname=org.apache.jetspeed.services.rundata.JetspeedRunDataService
services.ServletService.classname=org.apache.turbine.services.servlet.TurbineServletService
services.AssemblerBrokerService.classname=org.apache.turbine.services.assemblerbroker.TurbineAssemblerBrokerService
-services.LocalizationService.classname=org.apache.turbine.services.localization.TurbineLocalizationService
+#
services.LocalizationService.classname=org.apache.turbine.services.localization.TurbineLocalizationService
+services.LocalizationService.classname=org.apache.jetspeed.services.customlocalization.JetspeedLocalizationService
services.MimeTypeService.classname=org.apache.turbine.services.mimetype.TurbineMimeTypeService
services.GlobalCacheService.classname=org.apache.turbine.services.cache.TurbineGlobalCacheService
services.SchedulerService.classname=org.apache.turbine.services.schedule.TurbineSchedulerService
@@ -379,6 +380,7 @@
services.TemplateService.classname=org.apache.turbine.services.template.TurbineTemplateService
#services.XSLTService.classname=org.apache.turbine.services.xslt.TurbineXSLTService
services.StateManagerService.classname=org.apache.jetspeed.services.statemanager.JetspeedHttpStateManagerService
+services.ResourceService.classname=org.apache.turbine.services.resources.TurbineResourceService
# Turn on the appropriate template service.
services.JspService.classname=org.apache.turbine.services.jsp.TurbineJspService
1.29 +11 -0 jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg
Index: portlets.xreg
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- portlets.xreg 29 Oct 2002 18:35:53 -0000 1.28
+++ portlets.xreg 14 Nov 2002 20:30:24 -0000 1.29
@@ -191,4 +191,15 @@
<url cachedOnURL="true"/>
</portlet-entry>
+ <portlet-entry name="ChangeLanguage" hidden="false" type="instance"
application="false">
+ <security-ref parent="default"/>
+ <meta-info>
+ <title>Change language portlet</title>
+ <description>Change language portlet</description>
+ </meta-info>
+
<classname>org.apache.jetspeed.portal.portlets.language.ChangeLanguagePortlet</classname>
+ <media-type ref="html"/>
+ <url cachedOnURL="true"/>
+ </portlet-entry>
+
</registry>
1.1 jakarta-jetspeed/webapp/images/ic-de.gif
<<Binary file>>
1.1 jakarta-jetspeed/webapp/images/ic-en.gif
<<Binary file>>
1.1 jakarta-jetspeed/webapp/images/ic-es.gif
<<Binary file>>
1.1 jakarta-jetspeed/webapp/images/ic-fr.gif
<<Binary file>>
1.1 jakarta-jetspeed/webapp/images/ic-it.gif
<<Binary file>>
1.1 jakarta-jetspeed/webapp/images/ic_ja.gif
<<Binary file>>
1.9 +2 -2 jakarta-jetspeed/xdocs/code-standards.xml
Index: code-standards.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/code-standards.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- code-standards.xml 17 Sep 2002 16:20:03 -0000 1.8
+++ code-standards.xml 14 Nov 2002 20:30:24 -0000 1.9
@@ -62,7 +62,7 @@
<subsection name="Style Checker">
<p>
A Java style checker, checkStyle, is part of the build process. This should aid
-in the development of readable code. Jetspeed currently works with version 2.3 of
+in the development of readable code. Jetspeed currently works with version 2.4 of
the checkStyle. For more information see <a
href="http://checkstyle.sourceforge.net">http://checkstyle.sourceforge.net</a>.
Here is a list of rules currently enforced by the style checker:
<ul>
--
To unsubscribe, e-mail: <mailto:jetspeed-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@;jakarta.apache.org>