Class DefaultEasyDeskLocalizationService

java.lang.Object
com.easydesk.localization.DefaultEasyDeskLocalizationService
All Implemented Interfaces:
EasyDeskLocalizationService, AutoCloseable

public class DefaultEasyDeskLocalizationService extends Object implements EasyDeskLocalizationService, AutoCloseable
EasyDeskLocalizationService 의 기본 구현 - ResourceBundle 기반.

Fulcrum 의 SimpleLocalizationServiceImpl/DefaultLocalizationService/LocaleTokenizer (Apache License 2.0) 의 동작을 그대로 옮겨 왔다:

  • 요청한 bundle 에 key 가 없으면 설정된 나머지 bundle 들에서 차례로 찾는다.
  • 요청 locale 의 bundle 이 없으면 기본 국가/언어를 붙여 보고, 그래도 없으면 기본 locale 의 bundle 을 쓴다.
  • format 은 MessageFormat 으로 인자를 채운다.
추가된 동작: 요청한 locale 의 어느 bundle 에도 key 가 없으면 (번역 누락) 기본 locale 의 값을 쓴다 (LocalizationConfig.fallbackToDefaultLocale(boolean) 로 끌 수 있다). 달라진 점: Avalon/Turbine/servlet 의존성이 없고, bundle cache 는 요청 locale 기준의 thread-safe map 이며, locale 문자열은 ko-KR 뿐 아니라 ko_KR 형식도 받는다.

Spring 에서는 LocalizationConfiguration 이 bean 으로 만들고, Spring 밖에서는 Localization.getService() 로 같은 instance 를 쓴다. Java 9+ 의 ResourceBundle 은 .properties 를 UTF-8 로 읽는다.

Author:
YounghoCho