다국어 처리
- 웹 브라우저를 사용하는 국가에 따라 다양한 언어 및 지역을 지원하는 서비스
- JSP페이지에 JSTL의 fm태그를 이용하면 언어별로 페이지를 따로 만들 필요 없이 간단하게 다국어를 지원할 수 있다.
- 다양한 언어와 지역에 적용될 수 있도록 하는 국제화와 언어별 구성 요소를 추가하여 특정 지역의 언어나 문화에 맞추는 지역화를 포함한다.
지역화
- 사용 국가별 환경에서 특정 언어와 지역에 맞게 적합화 하는 것 (L10n으로 표기)
- 숫자, 날짜 시간의 형식
- 화폐의 표시 등
지역화 예시
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.text.NumberFormat"%>
<%@ page import="java.text.DateFormat"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.util.Locale"%>
<!DOCTYPE html>
<html>
<head>
<title>Internationalization</title>
</head>
<body>
<h3>현재 로케일의 국가, 날씨, 통화</h3>
<%
Locale locale = request.getLocale();
Date currentDate = new Date();
DateFormat dateFormat = DateFormat.getDateInstance(
DateFormat.FULL, locale);
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
%>
<p>국가 : <%=locale.getDisplayCountry() %></p>
<p>날짜 : <%=dateFormat.format(currentDate) %></p>
<p>숫자 : <%=numberFormat.format(12345.67) %></p>
</body>
</html>

국제화
- 여러 국가에서 사용할 수 있도록 다국어를 지원하는 것
- i18n으로 표기
국제화 예시1
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<title>JSTL fmt 태그 라이브러리</title>
</head>
<body>
<h2>국제화</h2>
<!-- 숫자 : 3,200,100 -->
<p>숫자 : <fmt:formatNumber value="3200100"/></p>
<!-- 3,200,100 -->
<p>숫자 : <fmt:formatNumber value="3200100" type="number"/></p>
<!-- 3200100 -->
<p>숫자 : <fmt:formatNumber value="3200100" type="number"
groupingUsed="false"/></p>
<!-- ₩3,200,100 -->
<p>숫자 : <fmt:formatNumber value="3200100" type="currency"
groupingUsed="true"/></p>
<!-- 금3,200,100 -->
<p>숫자 : <fmt:formatNumber value="3200100" type="currency"
currencySymbol="금"/></p>
<!-- 45% -->
<p>숫자 : <fmt:formatNumber value="0.45" type="percent" /></p>
<!-- 가장 많이 사용!! 천단위 구분기호. 소수점 2자리-->
<p>숫자 : <fmt:formatNumber value="3200100.45" pattern="#,#00.0#" /></p>
</body>
</html>

국제화 예시 2
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.Date"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<h2>국제화</h2>
<!-- 2023.7.7 -->
<p><fmt:formatDate value="<%=new Date() %>" type="date"/></p>
<!-- 오전 9:38:44 -->
<p><fmt:formatDate value="<%=new Date() %>" type="time"/></p>
<!-- 2023.7.7 오전 9:38:44 -->
<p><fmt:formatDate value="<%=new Date() %>" type="both"
dateStyle="default" timeStyle="default"/></p>
<!-- 23.7.7 오전 9:40 -->
<p><fmt:formatDate value="<%=new Date() %>" type="both"
dateStyle="short" timeStyle="short"/></p>
<p><fmt:formatDate value="<%=new Date() %>" type="both"
dateStyle="medium" timeStyle="medium"/></p>
<p><fmt:formatDate value="<%=new Date() %>" type="both"
dateStyle="long" timeStyle="long"/></p>
<p><fmt:formatDate value="<%=new Date() %>" type="both"
dateStyle="full" timeStyle="full"/></p>
<!-- 가장 많이 사용됨!!!
oracle Date 자료형
-->
<p><fmt:formatDate value="<%=new Date() %>" type="both"
pattern="yyyy-MM-dd"/></p>
<p><fmt:formatDate value="<%=new Date() %>" type="both"
pattern="yyyy-MM-dd hh:mm:ss"/></p>
</body>
</html>

JSTL fmt 태그
- 다국어 문서 처리르 위한 국제화 및 지역화 태그

- JSTL fmt 태그의 종류


'JSP' 카테고리의 다른 글
| [JSP] 예외처리 (1) | 2023.07.11 |
|---|---|
| [JSP] 시큐리티 (0) | 2023.07.10 |
| [JSP] 유효성 검사 (0) | 2023.07.05 |
| [JSP] 파일 업로드 (0) | 2023.07.05 |
| [JSP] 폼(form) 태그 (0) | 2023.07.03 |