[UI5] Translatable Texts

토마토·2024년 7월 15일

UI5

목록 보기
9/9

🌿 Translatable Texts

UI의 텍스트를 별도의 리소스파일로 옮기는 작업
모든 텍스트를 한 곳에 모으로 다른 언어로 번역이 쉽도록 해준다

🌱 text.properties 생성

  • 경로: webapp>text>text.properties
  • 실무에서는 기본 세팅 설정 시에 주로 사용
  • properties 파일은 각 글자마다 key-value 를 쌍으로 보유
ButtonTitle=Class 5
LabelText=Resource Model Training

🌱 패키지경로와 bundleName

  • 패키지 경로 추가
    - "sap/ui/model/resource/ResourceModel"
  • 모델 생성
    - bundleName 입력 "sap/ui/model/resource/ResourceModel"
    - 모델명 부여 this.getView().setModel(oRModel, "RSM");
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/ui/model/json/JSONModel",
    "sap/ui/model/resource/ResourceModel",
],
function (Controller, JSONModel, ResourceModel) {
    "use strict";

let oRModel = new ResourceModel({
    bundleName: "sync5.cl5.fioritraining01.text.text" 
});

this.getView().setModel(oRModel, "RSM");

✔️ bundleName 어느 경로의 파일을 읽어올거냐?
✔️ 루트폴더 ui5.walkthroughi18n 폴더 중 i18n properties 읽어라

🌱 View

<Label text="{RSM>LabelText}">

결과

참고

✔️ bundleName 위치

webapp > i18n > i18n.properties

✔️ i18n과 properties

출처: 주영멘토님🙇‍♀️🫶

profile
멋쟁이 토마토

0개의 댓글