731 } 732 733 /** Find a localized string in the resource bundle. 734 * Because this method is static, it ignores the locale. 735 * Use localize(key, args) when possible. 736 * @param key The key for the localized string. 737 * @param args Fields to substitute into the string. 738 */ 739 public static String getLocalizedString(String key, Object ... args) { 740 return JavacMessages.getDefaultLocalizedString(PrefixKind.COMPILER_MISC.key(key), args); 741 } 742 743 /** Find a localized string in the resource bundle. 744 * @param key The key for the localized string. 745 * @param args Fields to substitute into the string. 746 */ 747 public String localize(String key, Object... args) { 748 return localize(PrefixKind.COMPILER_MISC, key, args); 749 } 750 751 /** Find a localized string in the resource bundle. 752 * @param key The key for the localized string. 753 * @param args Fields to substitute into the string. 754 */ 755 public String localize(PrefixKind pk, String key, Object... args) { 756 if (useRawMessages) 757 return pk.key(key); 758 else 759 return messages.getLocalizedString(pk.key(key), args); 760 } 761 // where 762 // backdoor hook for testing, should transition to use -XDrawDiagnostics 763 private static boolean useRawMessages = false; 764 765 /*************************************************************************** 766 * raw error messages without internationalization; used for experimentation 767 * and quick prototyping 768 ***************************************************************************/ 769 770 /** print an error or warning message: | 731 } 732 733 /** Find a localized string in the resource bundle. 734 * Because this method is static, it ignores the locale. 735 * Use localize(key, args) when possible. 736 * @param key The key for the localized string. 737 * @param args Fields to substitute into the string. 738 */ 739 public static String getLocalizedString(String key, Object ... args) { 740 return JavacMessages.getDefaultLocalizedString(PrefixKind.COMPILER_MISC.key(key), args); 741 } 742 743 /** Find a localized string in the resource bundle. 744 * @param key The key for the localized string. 745 * @param args Fields to substitute into the string. 746 */ 747 public String localize(String key, Object... args) { 748 return localize(PrefixKind.COMPILER_MISC, key, args); 749 } 750 751 public String localize(JCDiagnostic.DiagnosticInfo diagInfo) { 752 if (useRawMessages) { 753 return diagInfo.key(); 754 } else { 755 return messages.getLocalizedString(diagInfo.key(), diagInfo.args); 756 } 757 } 758 759 /** Find a localized string in the resource bundle. 760 * @param key The key for the localized string. 761 * @param args Fields to substitute into the string. 762 */ 763 public String localize(PrefixKind pk, String key, Object... args) { 764 if (useRawMessages) 765 return pk.key(key); 766 else 767 return messages.getLocalizedString(pk.key(key), args); 768 } 769 // where 770 // backdoor hook for testing, should transition to use -XDrawDiagnostics 771 private static boolean useRawMessages = false; 772 773 /*************************************************************************** 774 * raw error messages without internationalization; used for experimentation 775 * and quick prototyping 776 ***************************************************************************/ 777 778 /** print an error or warning message: |