0
我在我的web服務下面的代碼國際Axis2中的客戶
package com.manumehrotra.hs.samples.internationalization;
import java.util.MissingResourceException;
import javax.servlet.http.HttpServletRequest;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.transport.http.HTTPConstants;
public class SampleInternationalizationHS {
public String getInternationalizedMessage(){
System.out.println("in getInternationalizedMessage");
String retVal = null;
String language = null;
// Get the current MessageContext
MessageContext msgContext = MessageContext.getCurrentMessageContext();
// Get HttpServletRequest from Message Context
Object requestProperty = msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
if (requestProperty != null && requestProperty instanceof HttpServletRequest) {
HttpServletRequest request = (HttpServletRequest) requestProperty;
language = request.getLocale().getLanguage();
// language codes are available at - http://www.loc.gov/standards/iso639-2/php/code_list.php
}
System.out.println(language);
String msg_key = "samplemsg_en";
try {
msg_key = "samplemsg_"+language;
} catch (Exception e) {
msg_key = "samplemsg_en";
}
System.out.println(msg_key);
try {
retVal = Messages.getMessage(msg_key, "Jack");
} catch (MissingResourceException mre) {
// do nothing...
System.out.println("resource not found");
}
System.out.println("returning "+retVal);
return retVal;
}
}
我想知道如何在我的Java客戶端設置不同的區域設置值,以便上面提到的Web服務代碼識別它。
目前只有「en」被識別。