Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
LocalizationManager | 38 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.localization; | |
21 | ||
22 | import java.util.Locale; | |
23 | ||
24 | import org.xwiki.component.annotation.Role; | |
25 | ||
26 | /** | |
27 | * Internationalization service based on key/property values. The key is the id of the message being looked for, and the | |
28 | * returned value is the message in the specified language. | |
29 | * <p> | |
30 | * Properties are looked for in several {@link TranslationBundle bundles}, in the order of their | |
31 | * {@link TranslationBundle#getPriority() priority}. The first translation found in one of these bundles is the one | |
32 | * returned. If the property is not found in any of these sources, then null is returned. | |
33 | * | |
34 | * @version $Id: 212b8e4a9247da58267fc632fcdd96f9b4ff01d1 $ | |
35 | * @since 4.3M2 | |
36 | */ | |
37 | @Role | |
38 | public interface LocalizationManager | |
39 | { | |
40 | /** | |
41 | * Find a translation in the specified locale. | |
42 | * | |
43 | * @param key the key identifying the message to look for | |
44 | * @param locale the {@link Locale} for which this translation is searched. The result might me associated to a | |
45 | * different {@link Locale} (for example getting the {@code fr} translation when asking for the | |
46 | * {@code fr_FR} one). | |
47 | * @return the translation in the defined language | |
48 | * @see LocalizationManager | |
49 | */ | |
50 | Translation getTranslation(String key, Locale locale); | |
51 | ||
52 | /** | |
53 | * Find a bundle. | |
54 | * | |
55 | * @param bundleType a hint identifying the bundle type. | |
56 | * @param bundleId the identifier of the bundle, for example a wiki document name, or the URL to a | |
57 | * <tt>.properties</tt> file. | |
58 | * @return the {@link TranslationBundle} or null if none could be found | |
59 | * @throws TranslationBundleDoesNotExistsException when no bundle could be found for the passed identifier | |
60 | * @throws TranslationBundleFactoryDoesNotExistsException when no bundle factory could be found for the passed type | |
61 | * @since 4.5M1 | |
62 | */ | |
63 | TranslationBundle getTranslationBundle(String bundleType, String bundleId) | |
64 | throws TranslationBundleDoesNotExistsException, TranslationBundleFactoryDoesNotExistsException; | |
65 | ||
66 | /** | |
67 | * Registers a resource location as a possible localization bundle that should be used in the current execution. The | |
68 | * order in which resource of the same type are considered when searching for a translation corresponds to the order | |
69 | * in which they were pulled. Each execution (generally a client request) has its own list of pulled resources, and | |
70 | * at the end of an execution, its list of pulled resources is cleared. | |
71 | * | |
72 | * @param bundleType a hint identifying the bundle type. | |
73 | * @param bundleId the identifier of the bindle, for example a wiki document name, or the URL to a | |
74 | * <tt>.properties</tt> file. | |
75 | * @throws TranslationBundleDoesNotExistsException when no bundle could be found for the passed identifier | |
76 | * @throws TranslationBundleFactoryDoesNotExistsException when no bundle factory could be found for the passed type | |
77 | */ | |
78 | void use(String bundleType, String bundleId) | |
79 | throws TranslationBundleDoesNotExistsException, TranslationBundleFactoryDoesNotExistsException; | |
80 | } |