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.cburch.logisim.util.LocaleManager.java

private void loadLocale(Locale loc) {
    String bundleName = dir_name + "/" + loc.getLanguage() + "/" + file_start;
    locale = ResourceBundle.getBundle(bundleName, loc);
}

From source file:es.pode.empaquetador.presentacion.avanzado.submanifiestos.gestor.GestorSubmanifiestosControllerImpl.java

public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.submanifiestos.gestor.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*/*from w w  w.j a  va2s  . c o m*/
     * Metodo de decision para el action. Analiza los parametros
     * actionSubmit (value de los botones submit) para redirigir al caso de
     * uso correspondiente. El actionSubmit llegara internacionalizado, por
     * lo que es necesario acceder al ResouceBundle para obtener el valor
     * correcto en la comparacion.
     */

    String result = null;
    String actionSubmit = form.getAction();
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle(APPLICATION_RESOURCES, locale);

    if (form.getAction() == (null)) {
        throw new ValidatorException(EXCEPTION);
    }

    else if (actionSubmit.equals(i18n.getString(AGREGAR))) {
        result = "Agregar";
    } else if (actionSubmit.equals(i18n.getString(DESAGREGAR))) {
        result = "Desagregar";
    } else if (actionSubmit.equals(i18n.getString(ELIMINAR))) {
        result = "Eliminar";
    } else {
        logger.error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ")");
    }

    return result;
}

From source file:es.pode.empaquetador.presentacion.secuencia.SecuenciaControllerImpl.java

public String selectAction(ActionMapping mapping, SelectActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String resultado = null;/*from   w w w  .  j a  va2s. co m*/

    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    String accion = form.getAction();

    if (accion.equals(i18n.getString("portal_empaquetado_secuencia.aceptar"))) {
        if ((form.getChoice() == null) || (form.getChoiceExit() == null) || (form.getFlow() == null)
                || (form.getForwardOnly() == null)) {
            throw new ValidatorException("{portal_empaquetado.exception}");
        }
    }

    if (form.getAction() == (null)) {
        throw new ValidatorException("{portal_empaquetado.exception}");
    }

    else if (accion.equals(i18n.getString("portal_empaquetado_secuencia.cancelar"))) {
        resultado = "Cancelar";
    } else if (accion.equals(i18n.getString("portal_empaquetado_secuencia.aceptar"))) {
        resultado = "Aceptar";
    } else if (accion.equals(i18n.getString("secuencia.valorPorDefecto"))) {
        resultado = "Default";
    }

    return resultado;
}

From source file:com.evolveum.midpoint.model.impl.validator.ResourceValidatorImpl.java

@NotNull
@Override//  w w w. ja  v  a 2 s. c  om
public ValidationResult validate(@NotNull PrismObject<ResourceType> resourceObject, @NotNull Scope scope,
        @Nullable Locale locale, @NotNull Task task, @NotNull OperationResult result) {

    final ResourceType resource = resourceObject.asObjectable();
    final ValidationResult vr = new ValidationResult();

    ResourceBundle bundle = ResourceBundle.getBundle(
            SchemaConstants.SCHEMA_LOCALIZATION_PROPERTIES_RESOURCE_BASE_PATH,
            locale != null ? locale : Locale.getDefault());

    ResourceSchema resourceSchema = null;
    try {
        resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceObject, prismContext);
    } catch (Throwable t) {
        vr.add(Issue.Severity.WARNING, CAT_SCHEMA, C_NO_SCHEMA,
                getString(bundle, CLASS_DOT + C_NO_SCHEMA, t.getMessage()),
                ObjectTypeUtil.createObjectRef(resourceObject), ItemPath.EMPTY_PATH);
    }

    ResourceValidationContext ctx = new ResourceValidationContext(resourceObject, scope, task, vr,
            resourceSchema, bundle);

    SchemaHandlingType schemaHandling = resource.getSchemaHandling();
    if (schemaHandling != null) {
        checkSchemaHandlingDuplicateObjectTypes(ctx, schemaHandling);
        checkSchemaHandlingDefaults(ctx, schemaHandling);
        checkSchemaHandlingObjectTypes(ctx, schemaHandling);
    }
    SynchronizationType synchronization = resource.getSynchronization();
    if (synchronization != null) {
        checkSynchronizationDuplicateObjectTypes(ctx, synchronization);
        int i = 1;
        for (ObjectSynchronizationType objectSync : resource.getSynchronization().getObjectSynchronization()) {
            checkObjectSynchronization(ctx, new ItemPath(ResourceType.F_SYNCHRONIZATION,
                    SynchronizationType.F_OBJECT_SYNCHRONIZATION, i), objectSync);
            i++;
        }
    }
    checkSynchronizationExistenceForSchemaHandlingObjectTypes(ctx);
    checkSchemaHandlingExistenceForSynchronizationObjectTypes(ctx);
    return ctx.validationResult;
}

From source file:it.eng.spagobi.commons.utilities.PortletUtilities.java

/**
 * Gets a localized message given its code and bundle
 * information. If there isn't any message matching to these infromation, a
 * warning is traced./*  w w  w.j  a  v  a 2s.c o m*/
 * 
 * @param code The message's code string
 * @param bundle The message's bundel string
 * 
 * @return A string containing the message
 */
public static String getMessage(String code, String bundle) {

    Locale locale = getLocaleForMessage();

    ResourceBundle messages = ResourceBundle.getBundle(bundle, locale);
    if (messages == null) {
        return null;
    }
    String message = code;
    try {
        message = messages.getString(code);
    } catch (Exception ex) {
        logger.warn("code [" + code + "] not found ", ex);
    }
    return message;
}

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

public String getText(Locale locale, String key, List parameters) {

    Iterator bundleListIterator = bundleList.iterator();
    ResourceBundle myResources = null;
    String label = "";
    while (bundleListIterator.hasNext()) {
        String bundle = (String) bundleListIterator.next();

        try {//from   ww  w . j av  a  2s.  co  m

            myResources = ResourceBundle.getBundle(bundle, locale);
            if (myResources != null) {
                String l = myResources.getString(key);
                if (l != null) {
                    MessageFormat mFormat = new MessageFormat(l);
                    String[] params = new String[parameters.size()];
                    params = (String[]) parameters.toArray(params);
                    l = mFormat.format(params);
                    label = l;
                    break;
                }
            }

        } catch (Exception e) {
            // Handle exception
        }

    }
    return label;
}

From source file:es.pode.modificador.presentacion.configurar.cambios.navegarLom.NavegarLomControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.configurar.cambios.navegarLom.NavegarLomController#guardarTermino(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.cambios.navegarLom.GuardarTerminoForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from   w w  w.j  a v  a2s.c  o  m*/
public final void guardarTermino(ActionMapping mapping,
        es.pode.modificador.presentacion.configurar.cambios.navegarLom.GuardarTerminoForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    String actionSubmit = form.getAction();
    java.util.Locale locale = (java.util.Locale) request.getSession()
            .getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    if (!actionSubmit.equals(i18n.getString("comun.cancelar"))) {
        String idTermino = form.getIdTermino();
        String terminoLom = form.getTerminoLom();

        if (logger.isDebugEnabled())
            logger.debug("guardarTermino() : idTermino = " + idTermino + " : terminoLom = " + terminoLom
                    + " : action = " + form.getAction());

        if (idTermino == null || terminoLom == null) {
            logger.error("Error en guardarTermino");
            throw new ValidatorException("{navegarLom.error}");
        }

        this.getCambioSession(request).setIdLomTerm(idTermino);
        this.getCambioSession(request).setLomTerm(terminoLom);
    }

}

From source file:ispok.pres.bb.VisitorEdit.java

public void delete() {
    visitorService.deleteVisitor(selectedVisitor.getId());

    FacesContext fc = FacesContext.getCurrentInstance();
    Locale l = fc.getViewRoot().getLocale();
    ResourceBundle rb = ResourceBundle.getBundle("ispok/pres/inter/ispok", l);
    fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, rb.getString("visitor_delete_success"),
            selectedVisitor.getFirstName() + " " + selectedVisitor.getLastName()));

}

From source file:com.jslsolucoes.tagria.lib.util.TagUtil.java

public static String getLocalized(String label, JspContext jspContext) {
    if (label.matches("\\{(.*?)\\}")) {
        String key = label.replaceAll("(\\{|\\})", "").trim();
        try {//  w  w w  .j  a va  2s . co m
            return ResourceBundle.getBundle("messages", locale(jspContext)).getString(key);
        } catch (MissingResourceException e) {
            logger.error("could not find key resource", e);
            return '!' + key + '!';
        }
    }
    return label;
}

From source file:es.pode.empaquetador.presentacion.avanzado.recursos.gestor.GestorRecursosControllerImpl.java

public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.recursos.gestor.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*//from w  w w.  j a v  a 2 s .  c  om
    * Metodo de decision para el action. Analiza los parametros
    * actionSubmit (value de los botones submit) para redirigir al caso de uso
    * correspondiente. El actionSubmit llegara
    * internacionalizado, por lo que es necesario acceder al ResouceBundle
    * para obtener el valor correcto en la comparacion.
    */

    String result = null;
    String actionSubmit = form.getAction();
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    if (form.getAction() == (null)) {
        throw new ValidatorException("{comunes.error.generico}");
    }

    else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.crear"))) {
        result = "Crear";
    } else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.importar"))) {
        result = "Importar";
    } else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.exportar"))) {
        result = "Exportar";
    } else if (actionSubmit.equals(i18n.getString("presentacion.avanzado.recursos.gestor.submit.eliminar"))) {
        result = "Eliminar";
    } else {

        Logger.getLogger(this.getClass())
                .error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";");
    }
    return result;
}