Example usage for java.util ResourceBundle getBundle

List of usage examples for java.util ResourceBundle getBundle

Introduction

In this page you can find the example usage for java.util ResourceBundle getBundle.

Prototype

@CallerSensitive
public static ResourceBundle getBundle(String baseName, Module module) 

Source Link

Document

Gets a resource bundle using the specified base name and the default locale on behalf of the specified module.

Usage

From source file:com.ejisto.modules.vertx.handler.Translations.java

@Override
public void addRoutes(RouteMatcher routeMatcher) {
    routeMatcher.get("/translations", request -> {
        final String lang = request.params().get("lang");
        CACHE.computeIfAbsent(lang,/*  w  ww .ja va 2 s  .  com*/
                k -> dumpMessages(ResourceBundle.getBundle("messages", Locale.forLanguageTag(k))));
        request.response().end(JSONUtil.encode(CACHE.get(lang)), "UTF-8");
    });
}

From source file:org.shredzone.cilla.site.renderer.CommentRendererStrategyImpl.java

@Override
public void setLocale(Locale locale) {
    super.setLocale(locale);
    bundle = ResourceBundle.getBundle("messages", locale);
}

From source file:TestConnector.java

@Override
public ResourceBundle getBundle(Locale locale) {
    return ResourceBundle.getBundle(GenericJdbcConnectorConstants.RESOURCE_BUNDLE_NAME, locale);
}

From source file:com.inkubator.hrm.web.converter.PaySalaryComponentConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (Objects.equals(data, HRMConstant.PAY_SALARY_COMPONENT_TUNJANGAN)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_tunjangan");
    } else if (Objects.equals(data, HRMConstant.PAY_SALARY_COMPONENT_POTONGAN)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_potongan");
    } else if (Objects.equals(data, HRMConstant.PAY_SALARY_COMPONENT_SUBSIDI)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_subsidi");
    }//w  ww.ja va 2 s.  c om
    return messages;
}

From source file:org.openmrs.module.openhmis.inventory.web.controller.InventoryMessageRenderController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView render(HttpServletRequest request) {
    // object to store keys from inventory and backboneforms
    Vector<String> keys = new Vector<String>();

    Locale locale = RequestContextUtils.getLocale(request);
    ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", locale);

    // store inventory message keys in the vector object
    keys.addAll(resourceBundle.keySet());

    // retrieve backboneforms messages
    BackboneMessageRenderController backboneController = new BackboneMessageRenderController();
    ModelAndView modelAndView = backboneController.render(request);

    // store backboneforms message keys in the vector object
    for (Map.Entry<String, Object> messageKeys : modelAndView.getModel().entrySet()) {
        Enumeration<String> messageKey = (Enumeration<String>) messageKeys.getValue();
        while (messageKey.hasMoreElements()) {
            String key = messageKey.nextElement();
            if (!keys.contains(key))
                keys.add(key);/*from  w  w  w. j  a v a2s. co m*/
        }
    }

    return new ModelAndView(ModuleWebConstants.MESSAGE_PAGE, "keys", keys.elements());
}

From source file:com.ibm.ids.example.ShowResult.java

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String safename = StringEscapeUtils.escapeHtml4(request.getParameter("name"));
    Locale locale = request.getLocale();
    ResourceBundle messages = ResourceBundle.getBundle("com.ibm.ids.example.Messages", locale);

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    // log what we received in a vulnerable way
    try {//from  w  w w  .  j ava2 s.c  o  m
        writeToVulnerableSink(getVulnerableSource(safename));
    } catch (Exception e) {
        // ignore this, we're just logging, right?
    }

    out.println("<HTML><HEAD><TITLE>Hello World</TITLE></HEAD><BODY>");
    if (safename == null) {
        String nobody = messages.getString("nobody");
        out.println(nobody);
    } else {
        out.println("Hello, " + safename);
    }
    out.println("</BODY></HTML>");
}

From source file:org.openmrs.module.openhmis.cashier.web.controller.CashierMessageRenderController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView render(HttpServletRequest request) {
    // object to store keys from cashier and backboneforms
    Vector<String> keys = new Vector<String>();

    // locate and retrieve cashier messages
    Locale locale = RequestContextUtils.getLocale(request);
    ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", locale);

    // store cashier message keys in the vector object
    keys.addAll(resourceBundle.keySet());

    // retrieve backboneforms messages
    BackboneMessageRenderController backboneController = new BackboneMessageRenderController();
    ModelAndView modelAndView = backboneController.render(request);

    // store backboneforms message keys in the vector object
    for (Map.Entry<String, Object> messageKeys : modelAndView.getModel().entrySet()) {
        Enumeration<String> messageKey = (Enumeration<String>) messageKeys.getValue();
        while (messageKey.hasMoreElements()) {
            String key = messageKey.nextElement();
            if (!keys.contains(key))
                keys.add(key);//from  ww  w  .  j  a  v a  2s. co  m
        }
    }

    return new ModelAndView(CashierWebConstants.MESSAGE_PAGE, "keys", keys.elements());
}

From source file:de.otto.mongodb.profiler.web.I18nInterceptor.java

@Override
public void postHandle(final HttpServletRequest request, final HttpServletResponse response,
        final Object handler, final ModelAndView modelAndView) throws Exception {

    if (modelAndView == null) {
        return;//from   w w  w.j av  a 2 s.c  om
    }

    final Locale locale = request.getLocale();
    final ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale);
    final ForgivingResourceBundleModel bundleModel = new ForgivingResourceBundleModel(bundle,
            BeansWrapper.getDefaultInstance());

    modelAndView.addObject(modelName, bundleModel);
}

From source file:com.salesmanager.core.util.PaymentUtil.java

public static Map<String, PaymentMethod> getPaymentMethods(int merchantId, Locale locale) throws Exception {

    Map payments = new HashMap();

    ResourceBundle bundle = ResourceBundle.getBundle("modules", locale);
    if (bundle == null) {
        log.error("Cannot load ResourceBundle checkout.properties");
    }// w  w  w  . j av  a2  s . c  o m

    ReferenceService rservice = (ReferenceService) ServiceFactory.getService(ServiceFactory.ReferenceService);

    CountryDescription countryDescription = CountryUtil.getCountryByIsoCode(locale.getCountry(), locale);

    Map modules = new HashMap();

    if (countryDescription != null) {
        modules = rservice.getPaymentMethodsMap(countryDescription.getId().getCountryId());
    }

    ConfigurationRequest requestvo = new ConfigurationRequest(merchantId, true,
            PaymentConstants.MODULE_PAYMENT);
    MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);
    ConfigurationResponse responsevo = mservice.getConfiguration(requestvo);
    List config = responsevo.getMerchantConfigurationList();

    if (config != null) {
        Iterator it = config.iterator();
        while (it.hasNext()) {

            MerchantConfiguration m = (MerchantConfiguration) it.next();

            String key = m.getConfigurationKey();
            if (key.equals(PaymentConstants.MODULE_PAYMENT_INDICATOR_NAME)) {// module
                // configured

                // if(m.getConfigurationValue().equals("true")) {

                PaymentMethod method = null;
                // try to retreive the module first
                if (payments.containsKey(m.getConfigurationValue1())) {

                    method = (PaymentMethod) payments.get(m.getConfigurationValue1());

                } else {

                    method = new PaymentMethod();

                }

                if (m.getConfigurationValue() != null && m.getConfigurationValue().equals("true")) {
                    //payments.remove(m
                    //      .getConfigurationValue1());
                    //continue;
                    method.setEnabled(true);
                }

                CoreModuleService cms = (CoreModuleService) modules.get(m.getConfigurationValue1());
                if (cms != null) {
                    method.setPaymentImage(cms.getCoreModuleServiceLogoPath());
                }

                method.setPaymentModuleName(m.getConfigurationValue1());
                if (bundle != null) {
                    try {
                        String label = bundle.getString("module." + m.getConfigurationValue1());
                        if (StringUtils.isBlank(label)) {
                            label = "";
                        }
                        method.setPaymentMethodName(label);
                        String text = bundle.getString("module.paymenttext." + m.getConfigurationValue1());
                        method.setPaymentModuleText(text);
                    } catch (Exception e) {
                    }
                }
                if (m.getConfigurationValue() != null && m.getConfigurationValue().equals("true")) {
                    method.setEnabled(true);
                }

                payments.put(m.getConfigurationValue1(), method);
                continue;
            }

            if (key.contains(PaymentConstants.MODULE_PAYMENT_GATEWAY)) {// gateway
                // module

                PaymentMethod method = null;
                // try to retreive the module first
                if (payments.containsKey(m.getConfigurationModule())) {

                    method = (PaymentMethod) payments.get(m.getConfigurationModule());

                } else {

                    method = new PaymentMethod();

                }

                IntegrationProperties props = null;
                /** ASSUMING PROPERTIES ARE IN CONFIGURATION_VALUE 2 **/
                if (!StringUtils.isBlank(m.getConfigurationValue2())) {
                    props = MerchantConfigurationUtil.getIntegrationProperties(m.getConfigurationValue2(), ";");
                }

                if (props != null && props.getProperties3() != null && props.getProperties3().equals("2")) {// use
                    // cvv
                    method.addConfig("CVV", "true");

                }

                // core_modules_services subtype
                method.setType(1);
                payments.put(m.getConfigurationModule(), method);
                continue;

            }

            if (key.contains(PaymentConstants.MODULE_PAYMENT)) {// single
                // payment
                // module

                PaymentMethod method = null;
                // try to retreive the module first
                if (payments.containsKey(m.getConfigurationModule())) {

                    method = (PaymentMethod) payments.get(m.getConfigurationModule());

                } else {

                    method = new PaymentMethod();

                }

                // core_modules_services subtype
                method.setType(0);
                method.addConfig("key", m.getConfigurationValue());
                method.addConfig("key1", m.getConfigurationValue1());
                method.addConfig("key2", m.getConfigurationValue2());

                payments.put(m.getConfigurationModule(), method);
                continue;

            }

        }
    }

    Set entries = payments.keySet();

    Map paymentMethods = new HashMap();

    for (Object o : entries) {
        String key = (String) o;

        PaymentMethod pm = (PaymentMethod) payments.get(key);

        if (pm.isEnabled()) {
            paymentMethods.put(pm.getPaymentModuleName(), pm);
        }
    }

    return paymentMethods;

}

From source file:io.github.robwin.swagger2markup.builder.document.SecurityDocument.java

public SecurityDocument(Swagger2MarkupConfig swagger2MarkupConfig, String outputDirectory) {
    super(swagger2MarkupConfig, outputDirectory);

    ResourceBundle labels = ResourceBundle.getBundle("lang/labels",
            swagger2MarkupConfig.getOutputLanguage().toLocale());
    SECURITY = labels.getString("security");
    TYPE = labels.getString("security_type");
    NAME = labels.getString("security_name");
    IN = labels.getString("security_in");
    FLOW = labels.getString("security_flow");
    AUTHORIZATION_URL = labels.getString("security_authorizationUrl");
    TOKEN_URL = labels.getString("security_tokenUrl");
}