Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
I18nAplicationProperties |
|
| 1.0;1 |
1 | package org.jtheque.core.managers.core.application; | |
2 | ||
3 | import org.jtheque.core.utils.SystemProperty; | |
4 | import org.jtheque.utils.collections.ArrayUtils; | |
5 | import org.springframework.context.support.ReloadableResourceBundleMessageSource; | |
6 | ||
7 | import java.util.Locale; | |
8 | ||
9 | /* | |
10 | * This file is part of JTheque. | |
11 | * | |
12 | * JTheque is free software: you can redistribute it and/or modify | |
13 | * it under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation, either version 3 of the License. | |
15 | * | |
16 | * JTheque is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
23 | */ | |
24 | ||
25 | /** | |
26 | * Properties contained in a i18n base name in the "i18n" folder of the core folder. | |
27 | * | |
28 | * @author Baptiste Wicht | |
29 | */ | |
30 | public final class I18nAplicationProperties implements ApplicationProperties { | |
31 | private final ReloadableResourceBundleMessageSource resourceBundle; | |
32 | ||
33 | /** | |
34 | * Construct a new I18nAplicationProperties. | |
35 | */ | |
36 | public I18nAplicationProperties(){ | |
37 | 0 | super(); |
38 | ||
39 | 0 | resourceBundle = new ReloadableResourceBundleMessageSource(); |
40 | ||
41 | 0 | resourceBundle.setBasename("file:" + SystemProperty.USER_DIR.get() + "i18n/application"); |
42 | 0 | } |
43 | ||
44 | @Override | |
45 | public String getName(){ | |
46 | 0 | return getMessage("name"); |
47 | } | |
48 | ||
49 | @Override | |
50 | public String getAuthor(){ | |
51 | 0 | return getMessage("author"); |
52 | } | |
53 | ||
54 | @Override | |
55 | public String getEmail(){ | |
56 | 0 | return getMessage("email"); |
57 | } | |
58 | ||
59 | @Override | |
60 | public String getSite(){ | |
61 | 0 | return getMessage("site"); |
62 | } | |
63 | ||
64 | @Override | |
65 | public String getCopyright(){ | |
66 | 0 | return getMessage("copyright"); |
67 | } | |
68 | ||
69 | /** | |
70 | * Return the message with the specified key in the application resource bundle. | |
71 | * | |
72 | * @param key The key of the message. | |
73 | * | |
74 | * @return The String value of the message with the specified key. | |
75 | */ | |
76 | private String getMessage(String key){ | |
77 | 0 | return resourceBundle.getMessage(key, ArrayUtils.ZERO_LENGTH_ARRAY, Locale.getDefault()); |
78 | } | |
79 | } |