Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

다국어 설정 및 대응 #72

Closed
Youngminah opened this issue Nov 1, 2021 · 0 comments
Closed

다국어 설정 및 대응 #72

Youngminah opened this issue Nov 1, 2021 · 0 comments
Labels

Comments

@Youngminah
Copy link
Owner

Youngminah commented Nov 1, 2021

다국어 설정 - 스토리보드편

image

  • Project -> Info -> Localizations에서 스토리보드마다 언어를 선책 할 수 있다

image

  • 설정 뒤 모습
  • 스토리보드상의 Object ID로 구별함

다국어 설정 - 코드편

image

  • 다국어의 해당 내용을 strings파일로 직접 작성 할 수 있다.

다국어 설정 - InfoPlist

image

  • infoplist에 관한 strings 파일을 똑같이 만든다.

InfoPlist
image

  • infoplist를 코드로 연다음에 identifier를 직접 이용할 수 있음.

image

  • 자동적으로 string으로 인식하기 때문에 strings파일에서 바로 가져다 사용하면 된다.

코드로 사용할 때 Extension + Enum 활용하기

extension String {
    func localized(tableName: String = "Localizable") -> String {
        return NSLocalizedString(self, tableName: tableName, bundle: .main, value: "", comment: "")
    }
}
enum LocalizableStrings: String {
    
    case welcome_text
    case data_backup
    case data_restore
    
    var localized: String {
        return self.rawValue.localized()
    }
    
    var localizecWithTable: String {
        return self.rawValue.localized(tableName: "Setting")
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant