Multi-state mode and multi-language support for Java schema design

Source: Internet
Author: User

As an object's creation pattern, polymorphic classes in polymorphic patterns can have multiple instances, and polymorphic classes must create, manage, and provide their own instances to the outside world. Readers reading this article, you can refer to the author of the "Java and Mode" (just published by the electronic Industry Press) in the relevant chapters.

Introduction to a real project

This is part of a real-world Wall Street finance website project for consumers worldwide. According to the project plan, the Web site system is database driven and supports 19 different languages, and more languages will be supported in the future. Consumers can choose the language they need when they log on to the system, and the system converts the static text and dynamic text of the website to the language of the user's choice according to the user's choice.

After discussion, the designers agreed to take a different approach to static text and dynamic text:

All the pages to the translation of the static text to translate the above, and the dynamic content on the Web page needs to be solved by the program.

After the research, the designers found that they need to solve the dynamic text of the "translation" problem, in fact, some static or semi static data in the database to "translate". The following is a typical data table:

Currency Code Currency name Monetary Mantissa
USD America (United States of America), dollars 2
CNY Renminbi, Yuan 2
EUR France, Euro 2
JPY Japan, Yen 0

Code Listing 1, a list of currencies prepared for English users.

The currency code is always the English code seen above, but the currency name should vary according to the language the user chooses. For example, the Chinese reader should be translated into the following table:

Currency Code Currency name Monetary Mantissa
USD United States of America (United States of America) 2
CNY China, RMB yuan 2
EUR France, Euro 2
JPY Japan, Japanese yen 0

Code Listing 2, a list of currencies prepared for Chinese users.

Such a table appears as a Drop-down menu on a Web page, where the user sees the currency name, and the currency code is used inside the system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.