1 / 32

Internationalization

Internationalization. I18N. ISO 639 language codes. website specification. Website displays user’s browser’s preferred language on first load User can change language using ‘language toggle’ User stays on same page when using language toggle. Resource Bundles. ctrl + ‘c’. # welcome page

arlais
Download Presentation

Internationalization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Internationalization I18N

  2. ISO 639 language codes

  3. website specification • Website displays user’s browser’s preferred language on first load • User can change language using ‘language toggle’ • User stays on same page when using language toggle

  4. Resource Bundles

  5. ctrl + ‘c’ # welcome page greeting=Welcome to the online home of Nice Doggy. introText=Enjoy browsing and learning more about our unique home delivery service bringing you dogs of all kinds for your delight and delectation to your doorstep. # categories Pet\ Dogs=Pet Dogs Dogs\ to\ Eat=Dogs to Eat Hunting\ Dogs=Hunting Dogs Fighting\ Dogs=Fighting Dogs

  6. Add Locale

  7. messages_ko편집 # welcome page greeting=나이스 도기 온라인 홈에 오신것을 환영합니다. introText=즐겁게 브라우즈하세요! 우리는 다양한 개, 옙은, 귀여운, 맛있는, 싸움하는... 고객님의 집으로 배달 가능! # categories Pet\ Dogs=애완 개 Dogs\ to\ Eat=먹을 개 Hunting\ Dogs=사냥 개 Fighting\ Dogs=싸움 개

  8. In web.xml

  9. LocalizationContext is in JSTL 1.1

  10. Finish index.jsp and category.jsp

  11. Language Toggle

  12. In header.jspf <%-- language selection widget --%> english| <div class=“bubble"> <a href = "chooseLanguage?language=ko"> 한국</a> </div>

  13. <%-- language selection widget --%> <c:choose> <c:when test="${pageContext.request.locale.language ne 'ko'}"> english </c:when> <c:otherwise> <c:urlvar="url" value="chooseLanguage"> <c:param name="language" value="en"/> </c:url> <div class="bubble"><a href="${url}">english</a></div> </c:otherwise> </c:choose> | <c:choose> <c:when test="${pageContext.request.locale.languageeq 'ko'}"> 한국 </c:when> <c:otherwise> <c:urlvar="url" value="chooseLanguage"> <c:param name="language" value="ko"/> </c:url> <div class="bubble"><a href="${url}">한국</a></div> </c:otherwise> </c:choose>

  14. http header field: Accept-Language ISO-639 language codes Accept-Language: ko, en

  15. Accept-Language: ko, en

  16. request.getLocale().getLanguage(); ${pageContext.request.locale.language}

  17. chooseLanguage?language=ko

  18. In header.jspf

  19. Get language from Http accept-language header (browser preference) Get language from jstl session object

  20. EL - two kinds of syntax . or [‘ ... ’]

  21. Two kinds of syntax ${applicationScope.categories} or ${applicationScope[‘categories’]}

  22. Get language from ${pageContext.request.locale.language} Get language from ${sessionScope[‘javax.servlet.jsp.jstl.fmt.locale session’]}

  23. <c:choose> <c:when test="${empty sessionScope['javax.servlet.jsp.jstl.fmt.locale.session']}"> <c:choose> <c:when test="${pageContext.request.locale.language ne 'ko'}"> english </c:when> <c:otherwise> <c:url var="url" value="chooseLanguage"> <c:param name="language" value="en"/> </c:url> <div class="bubble"> <a href="${url}">english</a> </div> </c:otherwise> </c:choose> | <c:choose> <c:when test="${pageContext.request.locale.language eq 'ko'}"> 한국 </c:when> <c:otherwise> <c:url var="url" value="chooseLanguage"> <c:param name="language" value="ko"/> </c:url> <div class="bubble"> <a href="${url}">한국</a> </div> </c:otherwise> </c:choose> </c:when> <c:otherwise> <c:choose> <c:when test="${sessionScope['javax.servlet.jsp.jstl.fmt.locale.session'] ne 'ko'}"> english </c:when> <c:otherwise> <c:url var="url" value="chooseLanguage"> <c:param name="language" value="en"/> </c:url> <div class="bubble"> <a href="${url}">english</a> </div> </c:otherwise> </c:choose> | <c:choose> <c:when test="${sessionScope['javax.servlet.jsp.jstl.fmt.locale.session'] ne 'en'}"> 한국 </c:when> <c:otherwise> <c:url var="url" value="chooseLanguage"> <c:param name="language" value="ko"/> </c:url> <div class="bubble"> <a href="${url}">한국</a> </div> </c:otherwise> </c:choose> </c:otherwise> </c:choose>

More Related