[ Team LiB ] |
![]() ![]() |
IntroductionThe audience for almost all web sites is global. Many sites have at least a subset of content that must be adapted to the language and nationality of their visitors, so that the visitor's browser formats numbers and dates properly and translates text into the proper language. An obvious example is a product documentation or help web site. What if most of your customers or viewers for this product speak a language other than English? Java provides tools that allow web developers to internationalize their sites. Before I show these tools, let's first explain a few terms that always appear in discussions of web site translation.
So how do you internationalize or localize a Java web site? This is a big subject and the topic of several books. The following recipes provide the basics of how to create properties files (called ResourceBundles). These files (they can also be implemented as Java classes) provide language translations for phrases that your web pages use. A servlet can then access these resources and provide different text versions according to the requester's locale. The recipes in this chapter also cover how to adapt JSP pages to visitors who speak different languages by using the JSTL tags. I begin by describing how to detect the locale of a request using a servlet or JSP. |
[ Team LiB ] |
![]() ![]() |