Содержание
- 2. Objectives After completing this lesson, you should be able to: Describe the advantages of localizing an
- 3. Why Localize? The decision to create a version of an application for international use often happens
- 4. A Sample Application Localize a sample application: Text-based user interface Localize menus Display currency and date
- 5. Locale A Locale specifies a particular language and country: Language An alpha-2 or alpha-3 ISO 639
- 6. Resource Bundle The ResourceBundle class isolates locale-specific data: Returns key/value pairs stored separately Can be a
- 7. Resource Bundle File Properties file contains a set of key/value pairs. Each key identifies a specific
- 8. Sample Resource Bundle Files Samples for French and Chinese MessagesBundle_fr_FR.properties menu1 = Régler à l'anglais menu2
- 9. Quiz Which bundle file represents a language of Spanish and a country code of US? MessagesBundle_ES_US.properties
- 10. Initializing the Sample Application PrintWriter pw = new PrintWriter(System.out, true); // More init code here Locale
- 11. Sample Application: Main Loop public void run(){ String line = ""; while (!(line.equals("q"))){ this.printMenu(); try {
- 12. The printMenu Method Instead of text, resource bundle is used. messages is a resource bundle. A
- 13. Changing the Locale To change the Locale: Set currentLocale to the desired language. Reload the bundle
- 14. Sample Interface with French After the French option is selected, the updated user interface looks like
- 15. Format Date and Currency Numbers can be localized and displayed in their local format. Special format
- 16. Initialize Date and Currency The application can show a local formatted date and currency. The variables
- 17. Displaying a Date Format a date: Get a DateFormat object based on the Locale. Call the
- 18. Customizing a Date DateFormat constants include: SHORT: Is completely numeric, such as 12.13.52 or 3:30pm MEDIUM:
- 19. Displaying Currency Format currency: Get a currency instance from NumberFormat. Pass the Double to the format
- 20. Quiz Which date format constant provides the most detailed information? LONG FULL MAX COMPLETE
- 22. Скачать презентацию