【问题标题】:Month Name in another Language - SwiftUI另一种语言的月份名称 - SwiftUI
【发布时间】:2022-01-26 19:24:43
【问题描述】:

大家好,我需要显示当前月份名称,为此我使用Date()formatted(.dateTime.month(.wide))

这样我可以得到当前月份的全名。

我的问题是我显示它的语言(即使在真实设备上)是英语,我需要用意大利语显示它,因为整个应用程序都是意大利语

很久以前我不需要做自动翻译的任何操作,但现在在我的设备上(iphone 13 pro max)我继续用英文查看它

有什么我忘了做的吗?你能帮帮我吗?

var date: Date = Date()
date.formatted(.dateTime.month(.wide))
// Return January instead Gennaio

【问题讨论】:

    标签: ios swift date translate


    【解决方案1】:

    还有一个locale 修饰符

    Text(date.formatted(.dateTime
                        .month(.wide)
                        .locale(.init(identifier: "it_IT"))))
    

    【讨论】:

    • 啊好吧...我必须强制代码所以..我没有忘记一些xcode设置
    猜你喜欢
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 2020-03-05
    • 2021-01-11
    • 1970-01-01
    • 2014-11-04
    • 2011-01-04
    • 2012-07-28
    相关资源
    最近更新 更多