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:caillou.company.clonemanager.gui.spring.SpringFxmlLoader.java

public static void changeLocale(Locale locale) {
    SpringFxmlLoader.currentLocale = locale;
    Group.GROUPA.setGuiValue(resourceBundle.getString("group1"));
    Group.GROUPB.setGuiValue(resourceBundle.getString("group2"));
    resourceBundle = ResourceBundle.getBundle("bundle.Main", SpringFxmlLoader.currentLocale);
}

From source file:org.wso2.carbon.springservices.ui.SpringServiceMaker.java

public SpringServiceMaker(ConfigurationContext context, Locale locale) {
    configContext = context;
    bundle = ResourceBundle.getBundle(BUNDLE, locale);
}

From source file:com.willwinder.universalgcodesender.i18n.Localization.java

/**
 * Loads the resource bundle with all translations for the given language and region
 *
 * @param language the language to load, ex: en, sv, de
 * @param region the region of the language to load, ex: US, SE, DE
 * @throws MissingResourceException if the resource bundle couldn't be found
 *///from   w w  w  .  ja  v a2  s.co m
private static void loadResourceBundle(String language, String region) throws MissingResourceException {
    Localization.region = region;
    Locale locale = new Locale(language, region);
    Locale.setDefault(locale);
    bundle = ResourceBundle.getBundle("resources.MessagesBundle", locale);
}

From source file:org.callistasoftware.netcare.core.api.messages.DefaultSystemMessage.java

protected ResourceBundle getResourceBundle() {
    return ResourceBundle.getBundle("messages", LocaleContextHolder.getLocale());
}

From source file:io.github.swagger2markup.internal.document.builder.SecurityDocumentBuilder.java

public SecurityDocumentBuilder(Swagger2MarkupConverter.Context context,
        Swagger2MarkupExtensionRegistry extensionRegistry, Path outputPath) {
    super(context, extensionRegistry, outputPath);

    ResourceBundle labels = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels",
            config.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");
}

From source file:at.alladin.rmbt.controlServer.QoSResultResource.java

@Post("json")
public String request(final String entity) {
    addAllowOrigin();/*  www.  jav a2s.c  om*/

    JSONObject request = null;

    final ErrorList errorList = new ErrorList();
    final JSONObject answer = new JSONObject();
    String answerString;

    System.out.println(MessageFormat.format(labels.getString("NEW_QOS_TESTRESULT_DETAIL"), getIP()));

    if (entity != null && !entity.isEmpty())
        // try parse the string to a JSON object
        try {
            request = new JSONObject(entity);

            String lang = request.optString("language");

            // Load Language Files for Client

            final List<String> langs = Arrays
                    .asList(settings.getString("RMBT_SUPPORTED_LANGUAGES").split(",\\s*"));

            if (langs.contains(lang)) {
                errorList.setLanguage(lang);
                labels = (PropertyResourceBundle) ResourceBundle.getBundle("at.alladin.rmbt.res.SystemMessages",
                        new Locale(lang));
            } else
                lang = settings.getString("RMBT_DEFAULT_LANGUAGE");

            if (conn != null) {
                final String testUuid = request.optString("test_uuid");
                long ts = System.nanoTime();
                QoSUtil.evaluate(settings, conn, new TestUuid(testUuid, UuidType.TEST_UUID), answer, lang,
                        errorList);
                long endTs = System.nanoTime() - ts;
                answer.put("evaluation",
                        "Time needed to evaluate test result: " + ((float) endTs / 1000000f) + " ms");
            } else {
                errorList.addError("ERROR_DB_CONNECTION");
            }

        } catch (final JSONException e) {
            errorList.addError("ERROR_REQUEST_JSON");
            e.printStackTrace();
        } catch (SQLException e) {
            errorList.addError("ERROR_DB_CONNECTION");
            e.printStackTrace();
        } catch (HstoreParseException e) {
            errorList.addErrorString(e.getMessage());
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            errorList.addError("ERROR_REQUEST_JSON");
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedOperationException e) {
            e.printStackTrace();
            errorList.addError("ERROR_REQUEST_QOS_RESULT_DETAIL_NO_UUID");
        }

    else
        errorList.addErrorString("Expected request is missing.");

    try {
        answer.putOpt("error", errorList.getList());
    } catch (final JSONException e) {
        System.out.println("Error saving ErrorList: " + e.toString());
    }

    answerString = answer.toString();

    //System.out.println(answerString);

    return answerString;
}

From source file:no.met.jtimeseries.marinogram.MarinogramPlot.java

public MarinogramPlot(int width, String language) {
    this.width = width;
    this.language = language;
    locale = new Locale(language);
    messages = ResourceBundle.getBundle("messages", locale);
}

From source file:com.hiperium.bo.manager.mail.EmailMessageManager.java

/**
 * Sends an email with the new user password.
 * /* w  w w.  j  a  v  a2  s.co  m*/
 * @param user
 * @throws javax.mail.internet.AddressException
 * @throws javax.mail.MessagingException
 */
public void sendNewPassword(User user) {
    try {
        this.log.debug("sendNewPassword() - START");
        // Create the corresponding user locale.
        Locale locale = null;
        if (StringUtils.isBlank(user.getLanguageId())) {
            locale = Locale.getDefault();
        } else {
            locale = new Locale(user.getLanguageId());
        }
        ResourceBundle resource = ResourceBundle.getBundle(EnumI18N.COMMON.value(), locale);

        // Get system properties
        Properties properties = System.getProperties();
        // Setup mail server
        properties.setProperty("mail.smtp.host", CloudEmailUser.HOST);
        properties.setProperty("mail.user", CloudEmailUser.USERNAME);
        properties.setProperty("mail.password", CloudEmailUser.PASSWORD);
        // Get the default Session object.
        Session session = Session.getDefaultInstance(properties);
        // Create a default MimeMessage object.
        MimeMessage message = new MimeMessage(session);
        // Set From: header field of the header.
        message.setFrom(new InternetAddress(CloudEmailUser.ADDRESS));
        // Set To: header field of the header.
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(user.getEmail()));
        // Set Subject: header field
        message.setSubject(resource.getString(GENERATED_USER_PASSWD_SUBJECT));
        // Send the actual HTML message, as big as you like
        message.setContent(MessageFormat.format(resource.getString(GENERATED_USER_PASSWD_CONTENT),
                user.getFirstname(), user.getLastname(), user.getPassword()), "text/html");
        // Send message
        Transport.send(message);
        this.log.debug("sendNewPassword() - END");
    } catch (AddressException e) {
        this.log.error("AddressException to send email to " + user.getEmail(), e);
    } catch (MessagingException e) {
        this.log.error("MessagingException to send email to " + user.getEmail(), e);
    }
}

From source file:com.fedroot.dacs.swing.DacsNoticePresentationDialog.java

/**
 * Set the locale used for getting localized
 * strings./*from  w w w.j av a 2  s.c  o  m*/
 *
 * @param locale Locale used to for i18n.
 */
@Override
public void setLocale(Locale locale) {
    labels = ResourceBundle.getBundle("com.fedroot.dacs.swing.DacsNoticePresentationDialog", locale);
}

From source file:io.github.swagger2markup.internal.document.builder.OverviewDocumentBuilder.java

public OverviewDocumentBuilder(Swagger2MarkupConverter.Context context,
        Swagger2MarkupExtensionRegistry extensionRegistry, Path outputPath) {
    super(context, extensionRegistry, outputPath);

    ResourceBundle labels = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels",
            config.getOutputLanguage().toLocale());
    OVERVIEW = labels.getString("overview");
    CURRENT_VERSION = labels.getString("current_version");
    VERSION = labels.getString("version");
    CONTACT_INFORMATION = labels.getString("contact_information");
    CONTACT_NAME = labels.getString("contact_name");
    CONTACT_EMAIL = labels.getString("contact_email");
    LICENSE_INFORMATION = labels.getString("license_information");
    LICENSE = labels.getString("license");
    LICENSE_URL = labels.getString("license_url");
    TERMS_OF_SERVICE = labels.getString("terms_of_service");
    URI_SCHEME = labels.getString("uri_scheme");
    HOST = labels.getString("host");
    BASE_PATH = labels.getString("base_path");
    SCHEMES = labels.getString("schemes");
}