日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

liferay 如何 用 国际化

發(fā)布時間:2024/1/23 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 liferay 如何 用 国际化 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1 首先寫三個language.properties文件如下圖


2 傳入?yún)?shù)判斷 為哪一種語言


String editon = request.getParameter("editon") == null ? "e" : request.getParameter("editon");String separator=File.separator;String path="en_US";if(editon.equals("e")){path="en_US";}else if(editon.equals("s")){path="zh_CN";}else if(editon.equals("t")){path="zh_tw";}
3 初始化配置取出相應(yīng)的值得

String paths = this.getServletContext().getRealPath("/") +"language" + separator + path + separator +"language.properties";System.out.println( " add_user_alert_rulers.jsp paths = " + paths);VtcMessage msg = new VtcMessage(paths);InternationalUtil international=new InternationalUtil();
4 VtcMessage.java?

package pcpapp;import java.io.FileInputStream; import java.io.InputStream; import java.io.PrintStream; import java.util.Properties;public class VtcMessage {private static Properties prpIniKeys = new Properties();private static String strMessageFileName = "strMessageFileName";private static String charsetName = "GBK";private boolean debug = false;public void setDebug(boolean blnDebug){this.debug = blnDebug;}public boolean getDebug(){return this.debug;}public void setCharset(String charsetName) {charsetName = charsetName;}public String getCharset() {return charsetName;}public String getMessage(String sErrorCode){String sTmp = "";try {sTmp = prpIniKeys.get(sErrorCode).toString();sTmp = new String(sTmp.getBytes("iso-8859-1"), charsetName);return sTmp;}catch (Exception e){e = e;sTmp = "The System/Error Message not found. Error Code No.: " + sErrorCode;return sTmp; } finally { } return sTmp;}public String getMessage(String sErrorCode, String sParam){int nStart = 0;String sTmp = new String();String sReturn = new String();try {sTmp = prpIniKeys.get(sErrorCode).toString();nStart = sTmp.indexOf("PARAMETER1");sReturn = sTmp.substring(0, nStart) + sParam + sTmp.substring(nStart + 10);sReturn = new String(sReturn.getBytes("iso-8859-1"), charsetName);return sReturn;}catch (Exception e){e = e;sReturn = "The System/Error Message not found. Error Code No.: " + sErrorCode;return sReturn; } finally { } return sReturn;}public String getMessage(String sErrorCode, String sParam1, String sParam2){int nStart1 = 0;String sTmp = "";String sReturn = "";try {sTmp = prpIniKeys.get(sErrorCode).toString();nStart1 = sTmp.indexOf("PARAMETER1");int nStart2 = sTmp.indexOf("PARAMETER2");sReturn = sTmp.substring(0, nStart1) + sParam1 + sTmp.substring(nStart1 + 10, nStart2) + sParam2 + sTmp.substring(nStart2 + 10);sReturn = new String(sReturn.getBytes("iso-8859-1"), charsetName);return sReturn;}catch (Exception e){e = e;sReturn = "The System/Error Message not found. Error Code No.: " + sErrorCode;return sReturn; } finally { } return sReturn;}public VtcMessage(){String strUatPath = "/ini/characterRes.ini";try{InputStream is = VtcMessage.class.getResourceAsStream(strUatPath);prpIniKeys.load(is);is.close();} catch (Exception e) {e.printStackTrace();}}public VtcMessage(String strUatPath){try{FileInputStream inpStreamIni = new FileInputStream(strUatPath);prpIniKeys.load(inpStreamIni);inpStreamIni.close();} catch (Exception e) {e.printStackTrace();}}public static void main(String[] args){VtcMessage vtcMsg = new VtcMessage();System.out.println(vtcMsg.getMessage("CN006006"));} }

6 internalUit.java

package com.cpcnet.mc.util;import java.lang.reflect.Field; import java.util.Properties;import pcpapp.VtcMessage;public class InternationalUtil extends VtcMessage{/*** ���?���?��?��������������*/public String getMessage(String sErrorCode, Class vtcClass) {String sTmp = "";try {if ("VtcMessage".equals(vtcClass.getSimpleName())) {Field field = vtcClass.getDeclaredField("prpIniKeys");field.setAccessible(true);Properties prpIniKeys = (Properties) field.get(null);sTmp=prpIniKeys.get(sErrorCode).toString();return sTmp;}else{super.getMessage(sErrorCode);}} catch (Exception e) {sTmp = "The System/Error Message not found. Error Code No.: "+ sErrorCode;return sTmp;}return sTmp;}}




總結(jié)

以上是生活随笔為你收集整理的liferay 如何 用 国际化的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。