- RAP Developer Guide에 쓰인 방법으로 정리

 

  • RCP의 국제화와 방법이 다른 이유 :
In RAP we have to deal with different languages for different user sessions. Indeed, the language can also change between requests within the same session. Therefore, we cannot store language related information statically in Message classes as this is done in RCP. Instead, we must use a different instance of the Message class for every language.

각기 다른 유저 세션을 위한 언어가 다르기 때문이다. 게다가 같은 세션의 request에서도 다른 language를 요구할수 있다.

그러므로 우리는 language를 RCP처럼 클래쓰 안에 staticaaly하게 정의하고 사용할수 없다. 대신에 message class(language설정의 위한 클래스)의 instance를 사용해야 한다.

 

 

[시작]

  • test.mail.message 패키지 생성 >  Messages 클래스 생성(만든 패키지에)

public class Messages {
 
    private static final String BUNDLE_NAME
      = "test.mail.message.messages"; //$NON-NLS-1$
    public String HelloWorld;


    private Messages() {
      // prevent instantiation
    }
   
    public static Messages get() {
      Class clazz = Messages.class;
      return ( Messages )RWT.NLS.getISO8859_1Encoded( BUNDLE_NAME, clazz );
    }
  }

 

 

  • test.mail.message 패키지에 properties 파일 생성

messages.properties                             - 디폴트 (찾을수 없을때 사용되는 파일)

messages_ko_KR.properties                   - 언어 코드, 국가 코드 : 한국

messages_en_US.properties

 

  • messages.properties 내용

HelloWorld = Hello

farewell = Goodbye.

 

  • messages_ko_KR.properties 내용

HelloWorld = 안녕

farewell = 잘가

 

 

  • properties 사용할 부분에 코드 삽입
  public void createPartControl( Composite parent ) {
    Label label = new Label ( parent, SWT.NONE );
    label.setText( Messages.get().HelloWorld );
    label.setSize( 80, 20 );

 

 

 

 

 

 

 

일단은 이렇게만 실행해보아도 properties 적용이 잘 된것을 확인 할 수 있다.

properties를 다른 폴더에 넣고 싶으면, javabuild에서 폴더를 생성후 path를 등록하면 될것 같고.

참조 사이트에 보면 war로 배포하여 동작하기 위해선 web.xml에

   <init-param>
      <param-name>commandline</param-name>
      <param-value>-registryMultiLanguage</param-value>    
    </init-param>
  를 추가해야 한다고 나와있다.

 

여튼 저튼 위와 같은 방법으로 적용으로 테스트 해보면 된다.

 

 


참조 사이트 :

eclipse RAP Developer Guide(internationalization) : http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Fadvanced%2Fdeployment.html

 

RWT.NLS javadoc : http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Freference%2Fapi%2Forg%2Feclipse%2Frwt%2FRWT.NLS.html


클래프 패스 문제 (java.util.MissingResourceException: Can't find bundle for base name javan.Res_test, locale ko_KR) : http://darky.egloos.com/1066166



posted by cozyboy
: