Package org.apache.cocoon.i18n

Examples of org.apache.cocoon.i18n.Bundle


     *
     * @param catalogueId if not null, this catalogue will be used instead of the default one.
     */
    private String getString(String key, String catalogueId, String defaultValue) {
        try {
            Bundle catalogue = defaultCatalogue;
            if (catalogueId != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(catalogueId);
                if (catalogueInfo == null) {
                    if (getLogger().isDebugEnabled())
                        debug("Catalogue not found: " + catalogueId + ", could not translate key " + key);
                    return defaultValue;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() + " from location " + catalogueInfo.getLocation() + " for locale " + locale + ", will not translate key " + key);
                    return defaultValue;
                }
            }
            Node res = (Node)catalogue.getObject(
                    I18N_CATALOGUE_PREFIX + "[@key='" + key + "']");

            String value = getTextValue(res);
            return value != null ? value : defaultValue;
        } catch (MissingResourceException e)  {
View Full Code Here


    // Helper method to retrieve a message from the dictionary.
    // A default value is returned if message is not found
    private MirrorRecorder getMirrorRecorder(String key, MirrorRecorder defaultValue) {
        try {
            Bundle catalogue = defaultCatalogue;
            if (currentCatalogueId != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(currentCatalogueId);
                if (catalogueInfo == null) {
                    if (getLogger().isDebugEnabled())
                        debug("Catalogue not found: " + currentCatalogueId + ", could not translate key " + key);
                    return defaultValue;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() + " from location " + catalogueInfo.getLocation() + " for locale " + locale + ", will not translate key " + key);
                    return defaultValue;
                }
            }
            MirrorRecorder value = new MirrorRecorder (
                    (Node)catalogue.getObject(
                            I18N_CATALOGUE_PREFIX + "[@key='" + key + "']"));

            if (value == null)
                return defaultValue;
View Full Code Here

     *
     * @param catalogueId if not null, this catalogue will be used instead of the default one.
     */
    private String getString(String key, String catalogueId, String defaultValue) {
        try {
            Bundle catalogue = defaultCatalogue;
            if (catalogueId != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(catalogueId);
                if (catalogueInfo == null) {
                    if (getLogger().isDebugEnabled())
                        debug("Catalogue not found: " + catalogueId + ", could not translate key " + key);
                    return defaultValue;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() + " from location " + catalogueInfo.getLocation() + " for locale " + locale + ", will not translate key " + key);
                    return defaultValue;
                }
            }
            Node res = (Node)catalogue.getObject(
                    I18N_CATALOGUE_PREFIX + "[@key='" + key + "']");

            String value = getTextValue(res);
            return value != null ? value : defaultValue;
        } catch (MissingResourceException e)  {
View Full Code Here

    // Helper method to retrieve a message from the dictionary.
    // A default value is returned if message is not found
    private MirrorRecorder getMirrorRecorder(String key, MirrorRecorder defaultValue) {
        try {
            Bundle catalogue = defaultCatalogue;
            if (currentCatalogueId != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(currentCatalogueId);
                if (catalogueInfo == null) {
                    if (getLogger().isDebugEnabled())
                        debug("Catalogue not found: " + currentCatalogueId + ", could not translate key " + key);
                    return defaultValue;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() + " from location " + catalogueInfo.getLocation() + " for locale " + locale + ", will not translate key " + key);
                    return defaultValue;
                }
            }
            MirrorRecorder value = new MirrorRecorder (
                    (Node)catalogue.getObject(
                            I18N_CATALOGUE_PREFIX + "[@key='" + key + "']"));

            if (value == null)
                return defaultValue;
View Full Code Here

                }
                return null;
            }
        }

        Bundle bundle = catalogue.getCatalogue();
        if (bundle == null) {
            // Can't translate
            getLogger().debug("Untranslated key: '" + key + "'");
            return null;
        }

        try {
            return (ParamSaxBuffer) bundle.getObject(key);
        } catch (MissingResourceException e)  {
            getLogger().debug("Untranslated key: '" + key + "'");
        }

        return null;
View Full Code Here

    private ParamSaxBuffer getMessage(String catalogueID, String key) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Getting key " + key + " from catalogue " + catalogueID);
        }
        try {
            Bundle catalogue = defaultCatalogue;
            if (catalogueID != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(catalogueID);
                if (catalogueInfo == null) {
                    if (getLogger().isWarnEnabled()) {
                        getLogger().warn("Catalogue not found: " + catalogueID +
                                         ", will not translate key " + key);
                    }
                    return null;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() +
                                      " from location " + catalogueInfo.getLocation() +
                                      " for locale " + locale +
                                      ", will not translate key " + key);
                    return null;
                }
            }
            return (ParamSaxBuffer)catalogue.getObject(key);
        } catch (MissingResourceException e)  {
            getLogger().debug("Untranslated key: '" + key + "'");
            return null;
        }
    }
View Full Code Here

     *
     * @param catalogueId if not null, this catalogue will be used instead of the default one.
     */
    private String getString(String key, String catalogueId, String defaultValue) {
        try {
            Bundle catalogue = defaultCatalogue;
            if (catalogueId != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(catalogueId);
                if (catalogueInfo == null) {
                    if (getLogger().isDebugEnabled())
                        debug("Catalogue not found: " + catalogueId + ", could not translate key " + key);
                    return defaultValue;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() + " from location " + catalogueInfo.getLocation() + " for locale " + locale + ", will not translate key " + key);
                    return defaultValue;
                }
            }
            Node res = (Node)catalogue.getObject(
                    I18N_CATALOGUE_PREFIX + "[@key='" + key + "']");

            String value = getTextValue(res);
            return value != null ? value : defaultValue;
        } catch (MissingResourceException e)  {
View Full Code Here

    // Helper method to retrieve a message from the dictionary.
    // A default value is returned if message is not found
    private MirrorRecorder getMirrorRecorder(String key, MirrorRecorder defaultValue) {
        try {
            Bundle catalogue = defaultCatalogue;
            if (currentCatalogueId != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(currentCatalogueId);
                if (catalogueInfo == null) {
                    if (getLogger().isDebugEnabled())
                        debug("Catalogue not found: " + currentCatalogueId + ", could not translate key " + key);
                    return defaultValue;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() + " from location " + catalogueInfo.getLocation() + " for locale " + locale + ", will not translate key " + key);
                    return defaultValue;
                }
            }
            MirrorRecorder value = new MirrorRecorder (
                    (Node)catalogue.getObject(
                            I18N_CATALOGUE_PREFIX + "[@key='" + key + "']"));

            if (value == null)
                return defaultValue;
View Full Code Here

    private ParamSaxBuffer getMessage(String catalogueID, String key) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Getting key " + key + " from catalogue " + catalogueID);
        }
        try {
            Bundle catalogue = defaultCatalogue;
            if (catalogueID != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(catalogueID);
                if (catalogueInfo == null) {
                    if (getLogger().isWarnEnabled()) {
                        getLogger().warn("Catalogue not found: " + catalogueID +
                                         ", will not translate key " + key);
                    }
                    return null;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() +
                                      " from location " + catalogueInfo.getLocation() +
                                      " for locale " + locale +
                                      ", will not translate key " + key);
                    return null;
                }
            }
            return (ParamSaxBuffer)catalogue.getObject(key);
        } catch (MissingResourceException e)  {
            getLogger().debug("Untranslated key: '" + key + "'");
            return null;
        }
    }
View Full Code Here

     *
     * @param catalogueId if not null, this catalogue will be used instead of the default one.
     */
    private String getString(String key, String catalogueId, String defaultValue) {
        try {
            Bundle catalogue = defaultCatalogue;
            if (catalogueId != null) {
                CatalogueInfo catalogueInfo = (CatalogueInfo)catalogues.get(catalogueId);
                if (catalogueInfo == null) {
                    if (getLogger().isDebugEnabled())
                        debug("Catalogue not found: " + catalogueId + ", could not translate key " + key);
                    return defaultValue;
                }
                try {
                    catalogue = catalogueInfo.getCatalogue();
                } catch (Exception e) {
                    getLogger().error("Error getting catalogue " + catalogueInfo.getName() + " from location " + catalogueInfo.getLocation() + " for locale " + locale + ", will not translate key " + key);
                    return defaultValue;
                }
            }
            Node res = (Node)catalogue.getObject(
                    I18N_CATALOGUE_PREFIX + "[@key='" + key + "']");

            String value = getTextValue(res);
            return value != null ? value : defaultValue;
        } catch (MissingResourceException e)  {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.i18n.Bundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.