Java多語言

來源:互聯網
上載者:User

    Java真是高產的語言,對於本地化語言還有相應的package。即ResourceBundle和Locale。具體property檔案的命名規則參見http://download.oracle.com/javase/tutorial/i18n/resbundle/concept.html。如果在java中使用,例子如下:

import java.util.ResourceBundle;

import java.util.Locale;

public
class hoho {

     public
static
void main(String[] args){

         ResourceBundle res =

             ResourceBundle.getBundle("test/ApplicationResource_zh_CN",Locale.CHINA);

         String title = res.getString("Logon.title");

         System.out.println(title);

     }

}

注意路徑是相對路徑,檔案尾碼去掉了properties。在jsp中只需要將properties檔案放入build/class目錄下,就可以直接使用properties檔案了。注意如果是中文先將配置好的檔案用native2ascii命令(jdk中bin目錄)將檔案直接轉成Unicode。同時保留中文檔案,防止以後如果要修改。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.