2014-09-09 2 views
0

JSF 기반 프로젝트에서 사용자에게 보내는 메시지의 로케일 파일이 다릅니다. 내가 내가 내가이 키와 assosiated 배열 또는 목록으로 모든 메시지를 원하는 하나의 문자열의다른 로케일의 모든 리소스 파일에서 키를 가져 오는 메시지

String message=ResourceBundle.getBundle("com.tech.resources.messages", 
       new Locale(loggedInUser.getLanguage())).getString("label.hostel.room.allocated"); 

대신 관리 빈에서 사용하고 키

를 사용하여 내 프로젝트에서 사용할 수있는 모든 로케일에서 메시지를 검색 할 모든 자원 번들은 messages.properties, messages_hin.properties 등과 같습니다.

답변

2

로케일 특정 번들을 얻은 다음 키로 메시지를 가져 오는 방법을 이미 알고 있었으므로 그 부분은 응답 할 필요가 없습니다. 귀하의 유일한 질문은 기본적으로 아래로 귀결됩니다 :

지원되는 모든 로케일을 어떻게 얻을 수 있습니까?

Application#getSupportedLocales()으로 지원되는 모든 로캘을 가져올 수 있습니다.

Application application = FacesContext.getCurrentInstance().getApplication(); 
Iterator<Locale> supportedLocales = application.getSupportedLocales(); 

while (supportedLocales.hasNext()) { 
    Locale supportedLocale = supportedLocales.next(); 
    // ... 
} 
+0

완벽한 톤 감사합니다. – DilipAgarwal

관련 문제