Skip to content

Commit d401dd4

Browse files
committed
Added localization configuration
1 parent 5ba7578 commit d401dd4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)