All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.fulcrum.localization.LocalizationService Maven / Gradle / Ivy

The newest version!
package org.apache.fulcrum.localization;


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */


import java.util.Locale;
import java.util.ResourceBundle;

import jakarta.servlet.http.HttpServletRequest;

/**
 * 

* Provides localization functionality using the interface provided * by ResourceBundle, plus leverages a "search path" * style traversal of the ResourceBundle objects named by * the locale.default.bundles to discover a value for a * given key. *

* *

* It is suggested that one handle * dealing with concatenated messages * using MessageFormat and properties files. *

* * @author Jon S. Stevens * @author Daniel Rall * @author Leonard Richardson * @author Stephen McConnell * @author Thomas Vandahl * @version $Id$ */ public interface LocalizationService extends SimpleLocalizationService { String ROLE = LocalizationService.class.getName(); String SERVICE_NAME = ROLE; /** * A constant for the HTTP Accept-Language header. */ String ACCEPT_LANGUAGE = "Accept-Language"; /** * Convenience method to get a ResourceBundle based on name and * HTTP Accept-Language header. * * @param bundleName Name of bundle. * @param languageHeader A String with the language header. * @return A localized ResourceBundle. */ ResourceBundle getBundle(String bundleName, String languageHeader); /** * Convenience method to get a ResourceBundle based on HTTP * Accept-Language header in HttpServletRequest. * * @param req The HTTP request to parse the * Accept-Language of. * @return A localized ResourceBundle. */ ResourceBundle getBundle(HttpServletRequest req); /** * Convenience method to get a ResourceBundle based * on name and HTTP Accept-Language header from a * HttpServletRequest. * * @param bundleName Name of bundle. * @param req The HTTP request to parse the * Accept-Language of. * @return A localized ResourceBundle. */ ResourceBundle getBundle(String bundleName, HttpServletRequest req); /** * Attempts to pull the Accept-Language header out of * the HttpServletRequest object and then parse it. * If the header is not present, it will return a * null Locale. * * @param req The HTTP request to parse the * Accept-Language of. * @return The parsed locale. */ Locale getLocale(HttpServletRequest req); /** * Parses the Accept-Language header and attempts to * create a Locale from it. * * @param languageHeader The language header (i.e. en, es;q=0.8, * zh-TW;q=0.1), or null for the locale * corresponding to the default language and country. * @return The parsed locale, or a locale corresponding to the * language and country defaults. */ Locale getLocale(String languageHeader); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy