本地化iOS 14动态小部件配置 [英] Localize iOS 14 dynamic widget configuration

查看:128
本文介绍了本地化iOS 14动态小部件配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据应用程序语言为窗口小部件加载不同的配置,但是当我使用类似的内容时:

I am trying to load different configuration for the widgets depending on the app language, but when I use something like:

Locale.preferredLanguages
Bundle.main.preferredLocalizations
Bundle.main.localizations

所有人都返回"en"仅在IntentExtensionTarget中.

all of them are returning "en" only in IntentExtensionTarget.

这是我使用代码的示例:

here is an example where I am using the code:

extension IntentHandler: ReciterAndSurahIntentHandling {
    
    func provideSurahOptionsCollection(for intent: ReciterAndSurahIntent, with completion: @escaping (INObjectCollection<NSString>?, Error?) -> Void) {
        
        Locale.preferredLanguages
        Bundle.main.preferredLocalizations
        Bundle.main.localizations
        // All of them return "en" only, and I have multiple localization for the app.
    }
}

推荐答案

您只能获得EN,因为描述和窗口小部件名称中的本地化基于设备语言.如果您尝试将设备语言设置为另一种语言,则应该进行本地化.到目前为止,无法在小部件描述和名称本地化中使用应用内语言.

You get EN only, because localization in description and widget names is based on device language. If you would try to set device language to a different one, localization should work. As for now, it is not possible to use in-app language on widget description and name localization.

这篇关于本地化iOS 14动态小部件配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆