LoginSignup
0
0

More than 1 year has passed since last update.

【個人的備忘】Swiftで端末の言語設定に合わせてテキストを切り替える

Last updated at Posted at 2021-06-20
    let langId = Locale.current.identifier.prefix(2)
    let langInt: Int

    init() {
        switch langId {
        case "ja":
            self.langInt = 0
        case "en":
            self.langInt = 1
        case "fr":
            self.langInt = 2
        default:
            self.langInt = 1
        }
    }

    func getText(textId: Int) -> String {
        return texts[textId][langInt]
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0