How to internationalize a Java web application?

前端 未结 3 1740
野的像风
野的像风 2020-11-22 02:39

I learnt from Google that Internationalization is the process by which I can make my web application to use all languages. I want to understand Unicode for the process of i

3条回答
  •  有刺的猬
    2020-11-22 03:19

    based on this tutorial, I am using the following on GAE - Google's App Engine:

    A jsp file as follows:

    <%@ page import="java.io.* %>
    <% 
      String lang = "fr"; //Assign the correct language either by page or user-selected or browser language etc.
      ResourceBundle RB = ResourceBundle.getBundle("app", new Locale(lang));
    %>                 
    
    
    <%@ page contentType="text/html;charset=UTF-8" language="java"%>
    
    
    
      

    <%= RB.getString("greeting") %>

    And adding the files named: app.properties (default) and app_fr.properties (and so on for every language). Each of these files should contain the strings you need as follows: key:value_in_language, e.g. app_fr.properties contains:

    greeting=Bonjour!
    

    app.properties contains:

    greeting=Hello!
    

    That's all

提交回复
热议问题