File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
src/main/java/localization Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ package localization ;
2
+
3
+ import config .DomainConfiguration ;
4
+ import org .springframework .stereotype .Component ;
5
+
6
+ import java .nio .charset .Charset ;
7
+ import java .util .Locale ;
8
+ import java .util .ResourceBundle ;
9
+
10
+ @ Component
11
+ public class LocaleText {
12
+
13
+ private static final Locale LOCALE = DomainConfiguration .APP_DOMAIN .getLocale ();
14
+
15
+
16
+ public static String get (final String key ) {
17
+
18
+ /*************************************************************************
19
+ ** The resource bundle by default uses the ISO 8859-1 character encoding
20
+ ** Making it compatible with the commonly used UTF-8 format
21
+ *************************************************************************/
22
+
23
+ final String value = ResourceBundle .getBundle ("locale" , LOCALE ).getString (key );
24
+ final byte [] utf8Bytes = value .getBytes (Charset .forName ("ISO-8859-1" ));
25
+ return new String (utf8Bytes , Charset .forName ("UTF-8" ));
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments