/** * Creates a new diagnostic handler. */ public JSweetDiagnosticHandler(TranspilationHandler transpilationHandler, JSweetContext context) { super(JavacMessages.instance(context)); this.context = context; this.transpilationHandler = transpilationHandler; }
public String getLocalizedString(Locale l, String key, Object... args) { if (l == null) l = getCurrentLocale(); return getLocalizedString(getBundles(l), key, args); }
/** Creates a JavacMessages object. * @param bundleName the name to identify the resource bundle of localized messages. */ public JavacMessages(String bundleName, Locale locale) throws MissingResourceException { bundleNames = List.nil(); bundleCache = new HashMap<Locale, SoftReference<List<ResourceBundle>>>(); add(bundleName); setCurrentLocale(locale); }
/** Gets the localized string corresponding to a key, formatted with a set of args. */ public String getLocalizedString(String key, Object... args) { return getLocalizedString(currentLocale, key, args); }
/** * Gets a localized string from the compiler's default bundle. */ // used to support legacy Log.getLocalizedString static String getDefaultLocalizedString(String key, Object... args) { return getLocalizedString(List.of(getDefaultBundle()), key, args); }
private void registerResourceBundle(JavacMessages messages) { // Without touch the class here, I'm getting a weird classloading error // when using Maven and not having <fork>true</fork> :( DeptectiveMessages.class.getName(); try { messages.add(l -> ResourceBundle.getBundle(DeptectiveMessages.class.getName(), l)); } // add(ResourceBundleHelper) doesn't exist in Java 8 catch (Throwable t) { registeredResourceBundle = false; } } }
public Locale getLocale() { return messages.getCurrentLocale(); }
@Deprecated static JavacMessages getDefaultMessages() { if (defaultMessages == null) defaultMessages = new JavacMessages(defaultBundleName); return defaultMessages; }
@Deprecated public static DiagnosticFormatter<JCDiagnostic> getFragmentFormatter() { if (fragmentFormatter == null) { fragmentFormatter = new BasicDiagnosticFormatter(JavacMessages.getDefaultMessages()); } return fragmentFormatter; }
public void setCurrentLocale(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } this.currentBundles = getBundles(locale); this.currentLocale = locale; }
/** Find a localized string in the resource bundle. * Because this method is static, it ignores the locale. * Use localize(key, args) when possible. * @param key The key for the localized string. * @param args Fields to substitute into the string. */ public static String getLocalizedString(String key, Object ... args) { return JavacMessages.getDefaultLocalizedString(PrefixKind.COMPILER_MISC.key(key), args); }
return; final JavacMessages messages = JavacMessages.instance(docenv().context); Locale locale = Locale.getDefault(); Printer printer = new Printer() {
public String getLocalizedString(Locale l, String key, Object... args) { if (l == null) l = getCurrentLocale(); return getLocalizedString(getBundles(l), key, args); }
/** Creates a JavacMessages object. * @param bundleName the name to identify the resource bundle of localized messages. */ public JavacMessages(String bundleName, Locale locale) throws MissingResourceException { bundleNames = List.nil(); bundleCache = new HashMap<Locale, SoftReference<List<ResourceBundle>>>(); add(bundleName); setCurrentLocale(locale); }
/** * Converts a String into a locale-dependent representation accordingly to a given locale. * * @param l locale object to be used for i18n * @param key locale-independent key used for looking up in a resource file * @param args localization arguments * @return a locale-dependent string */ protected String localize(Locale l, String key, Object... args) { return messages.getLocalizedString(l, key, args); }
/** * Gets a localized string from the compiler's default bundle. */ // used to support legacy Log.getLocalizedString static String getDefaultLocalizedString(String key, Object... args) { return getLocalizedString(List.of(getDefaultBundle()), key, args); }
public Locale getLocale() { return messages.getCurrentLocale(); }
@Deprecated static JavacMessages getDefaultMessages() { if (defaultMessages == null) defaultMessages = new JavacMessages(defaultBundleName); return defaultMessages; }
@Deprecated public static DiagnosticFormatter<JCDiagnostic> getFragmentFormatter() { if (fragmentFormatter == null) { fragmentFormatter = new BasicDiagnosticFormatter(JavacMessages.getDefaultMessages()); } return fragmentFormatter; }