List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static ResourceBundle getBundle(String baseName, Module module)
From source file:at.favre.tools.dconvert.ui.CLIInterpreter.java
public static Arguments parse(String[] args) { ResourceBundle strings = ResourceBundle.getBundle("bundles.strings", Locale.getDefault()); Options options = setupOptions(strings); CommandLineParser parser = new DefaultParser(); Arguments.Builder builder;//from w ww . j av a2s.c o m try { CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption("gui")) { return Arguments.START_GUI; } if (commandLine.hasOption("h") || commandLine.hasOption("help")) { printHelp(options); return null; } if (commandLine.hasOption("v") || commandLine.hasOption("version")) { System.out.println("Version: " + CLIInterpreter.class.getPackage().getImplementationVersion()); return null; } String scaleRawParam = commandLine.getOptionValue(SCALE_ARG).toLowerCase(); boolean dp = false; if (scaleRawParam.contains("dp")) { dp = true; scaleRawParam = scaleRawParam.replace("dp", "").trim(); } builder = new Arguments.Builder(new File(commandLine.getOptionValue(SOURCE_ARG)), Float.parseFloat(scaleRawParam)); if (dp && commandLine.hasOption(SCALE_IS_HEIGHT_DP_ARG)) { builder.scaleMode(EScaleMode.DP_HEIGHT); } else if (dp && !commandLine.hasOption(SCALE_IS_HEIGHT_DP_ARG)) { builder.scaleMode(EScaleMode.DP_WIDTH); } else { builder.scaleMode(EScaleMode.FACTOR); } if (commandLine.hasOption(DST_ARG)) { builder.dstFolder(new File(commandLine.getOptionValue(DST_ARG))); } float compressionQuality = Arguments.DEFAULT_COMPRESSION_QUALITY; if (commandLine.hasOption(COMPRESSION_QUALITY_ARG)) { compressionQuality = Float.valueOf(commandLine.getOptionValue(COMPRESSION_QUALITY_ARG)); } if (commandLine.hasOption(OUT_COMPRESSION_ARG)) { switch (commandLine.getOptionValue(OUT_COMPRESSION_ARG)) { case "strict": builder.compression(EOutputCompressionMode.SAME_AS_INPUT_STRICT); break; case "png": builder.compression(EOutputCompressionMode.AS_PNG); break; case "jpg": builder.compression(EOutputCompressionMode.AS_JPG, compressionQuality); break; case "gif": builder.compression(EOutputCompressionMode.AS_GIF); break; case "bmp": builder.compression(EOutputCompressionMode.AS_BMP); break; case "png+jpg": builder.compression(EOutputCompressionMode.AS_JPG_AND_PNG, compressionQuality); break; default: System.err.println( "unknown compression type: " + commandLine.getOptionValue(OUT_COMPRESSION_ARG)); } } Set<EPlatform> platformSet = new HashSet<>(EPlatform.values().length); if (commandLine.hasOption(PLATFORM_ARG)) { switch (commandLine.getOptionValue(PLATFORM_ARG)) { case "all": platformSet = EPlatform.getAll(); break; case "android": platformSet.add(EPlatform.ANDROID); break; case "ios": platformSet.add(EPlatform.IOS); break; case "win": platformSet.add(EPlatform.WINDOWS); break; case "web": platformSet.add(EPlatform.WEB); break; default: System.err.println("unknown mode: " + commandLine.getOptionValue(PLATFORM_ARG)); } builder.platform(platformSet); } if (commandLine.hasOption(UPSCALING_ALGO_ARG)) { builder.upScaleAlgorithm( EScalingAlgorithm.getByName(commandLine.getOptionValue(UPSCALING_ALGO_ARG))); } if (commandLine.hasOption(DOWNSCALING_ALGO_ARG)) { builder.upScaleAlgorithm( EScalingAlgorithm.getByName(commandLine.getOptionValue(DOWNSCALING_ALGO_ARG))); } if (commandLine.hasOption(ROUNDING_MODE_ARG)) { switch (commandLine.getOptionValue(ROUNDING_MODE_ARG)) { case "round": builder.scaleRoundingStragy(RoundingHandler.Strategy.ROUND_HALF_UP); break; case "ceil": builder.scaleRoundingStragy(RoundingHandler.Strategy.CEIL); break; case "floor": builder.scaleRoundingStragy(RoundingHandler.Strategy.FLOOR); break; default: System.err.println("unknown mode: " + commandLine.getOptionValue(ROUNDING_MODE_ARG)); } } if (commandLine.hasOption(THREADS_ARG)) { builder.threadCount(Integer.valueOf(commandLine.getOptionValue(THREADS_ARG))); } builder.skipUpscaling(commandLine.hasOption("skipUpscaling")); builder.skipExistingFiles(commandLine.hasOption(SKIP_EXISTING_ARG)); builder.includeAndroidLdpiTvdpi(commandLine.hasOption("androidIncludeLdpiTvdpi")); builder.verboseLog(commandLine.hasOption(VERBOSE_ARG)); builder.haltOnError(commandLine.hasOption("haltOnError")); builder.createMipMapInsteadOfDrawableDir(commandLine.hasOption("androidMipmapInsteadOfDrawable")); builder.antiAliasing(commandLine.hasOption("antiAliasing")); builder.enablePngCrush(commandLine.hasOption("postProcessorPngCrush")); builder.postConvertWebp(commandLine.hasOption("postProcessorWebp")); builder.dryRun(commandLine.hasOption("dryRun")); builder.enableMozJpeg(commandLine.hasOption("postProcessorMozJpeg")); builder.keepUnoptimizedFilesPostProcessor(commandLine.hasOption("keepOriginalPostProcessedFiles")); builder.iosCreateImagesetFolders(commandLine.hasOption("iosCreateImagesetFolders")); builder.clearDirBeforeConvert(commandLine.hasOption("clean")); return builder.build(); } catch (Exception e) { System.err.println("Could not parse args: " + e.getMessage()); } return null; }
From source file:caillou.company.clonemanager.gui.spring.SpringFxmlLoader.java
public SpringFxmlLoader() { resourceBundle = ResourceBundle.getBundle("bundle.Main", SpringFxmlLoader.currentLocale); changeLocale(currentLocale); }
From source file:ispok.converter.BirthDateConverter.java
@Override public Object getAsObject(FacesContext fc, UIComponent uic, String string) { logger.trace("Entering getAsObject()"); Locale locale = fc.getViewRoot().getLocale(); ResourceBundle rb = ResourceBundle.getBundle("ispok/pres/inter/ispok", locale); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); SimpleDateFormat sdf = (SimpleDateFormat) df; String pattern = sdf.toPattern(); String localPattern = sdf.toLocalizedPattern(); logger.debug("pattern: {}", pattern); logger.debug("localized pattern: {}", localPattern); Date date;//from ww w. j ava 2 s. c o m try { date = new SimpleDateFormat(pattern).parse(string); } catch (ParseException ex) { FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "invalid date", pattern); throw new ConverterException(msg); } if (date.after(new Date())) { FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, rb.getString("birthdate_invalid"), rb.getString("birthdate_valid_future")); throw new ConverterException(msg); } Calendar c = Calendar.getInstance(); c.set(1850, 1, 1); if (date.before(c.getTime())) { FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, rb.getString("birthdate_invalid"), rb.getString("birthdate_valid_past")); throw new ConverterException(msg); } return date; }
From source file:RBCPTest.java
private static void test(Locale locale) { ResourceBundle rb = ResourceBundle.getBundle("resources.RBControl", locale); System.out.println("locale: " + locale); System.out.println(" region: " + rb.getString("region")); System.out.println(" language: " + rb.getString("language")); System.out.println();/* ww w . j a va 2 s .c om*/ }
From source file:com.cronutils.descriptor.CronDescriptor.java
/** * Constructor creating a descriptor for given Locale * @param locale - Locale in which descriptions are given *//* w ww .j av a 2s . c o m*/ private CronDescriptor(Locale locale) { bundle = ResourceBundle.getBundle(BUNDLE, locale); }
From source file:org.openmrs.module.openhmis.backboneforms.web.controller.BackboneMessageRenderController.java
@RequestMapping(method = RequestMethod.GET) public ModelAndView render(HttpServletRequest request) { Locale locale = RequestContextUtils.getLocale(request); ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", locale); return new ModelAndView(BackboneWebConstants.MESSAGE_PAGE, "keys", resourceBundle.getKeys()); }
From source file:de.micromata.genome.util.i18n.ChainedResourceBundleTranslationResolver.java
@Override public I18NTranslationProvider getTranslationFor(Locale locale) { Map<String, Object> entries = new HashMap<>(); for (String resId : resIds) { ResourceBundle resbundle = ResourceBundle.getBundle(resId, locale); for (String key : resbundle.keySet()) { entries.putIfAbsent(key, resbundle.getObject(key)); }// ww w.jav a 2 s .co m } return new MapTranslationProvider(StringUtils.join(resIds, "_"), entries); }
From source file:com.moneydance.modules.features.importlist.util.Localizable.java
Localizable(final String localizableResource, final Locale locale) { this.resourceBundle = ResourceBundle.getBundle(localizableResource, locale); }
From source file:com.examples.with.different.packagename.concolic.MathRuntimeException.java
/** * Translate a string to a given locale. * @param s string to translate/* w ww. j av a 2 s . c om*/ * @param locale locale into which to translate the string * @return translated string or original string * for unsupported locales or unknown strings */ private static String translate(final String s, final Locale locale) { try { ResourceBundle bundle = ResourceBundle.getBundle("org.apache.commons.math.MessagesResources", locale); if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) { // the value of the resource is the translated string return bundle.getString(s); } } catch (MissingResourceException mre) { // do nothing here } // the locale is not supported or the resource is unknown // don't translate and fall back to using the string as is return s; }
From source file:com.cronutils.descriptor.CronDescriptor.java
/** * Default constructor. Considers Locale.UK as default locale */ private CronDescriptor() { bundle = ResourceBundle.getBundle(BUNDLE, DEFAULT_LOCALE); }