小编Nan*_*mar的帖子

如何使用 Swift 在 iOS 上获取 ISO 639-2 国家/地区代码

目前我使用了以下代码,但它只会返回两位数代码

    if let countryCode = (Locale.current as NSLocale).object(forKey: .countryCode) as? String {
      print("Code => \(countryCode)") //FR
    }
Run Code Online (Sandbox Code Playgroud)

但我需要三位数代码(FRA),请有人建议我获取 ISO

639-2 代码

我还检查了Apple文档,但我不知道如何获取确切的代码

在此输入图像描述

https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html#//apple_ref/doc/uid/10000171i-CH15

谢谢。

iphone ios swift swift2 swift3

5
推荐指数
1
解决办法
5902
查看次数

标签 统计

ios ×1

iphone ×1

swift ×1

swift2 ×1

swift3 ×1