简体   繁体   English

iOS应用中VoiceOver在什么情况下会自动切换语言

[英]Under what conditions does VoiceOver automatically switch language in an iOS app

My phone is set to en_us as system language, and I have added Swedish and French to the VoiceOver rotor languages.我的手机设置为 en_us 作为系统语言,并且我在 VoiceOver 转子语言中添加了瑞典语和法语。

After adding the languages I find that the VoiceOver/Safari combo automatically starts in the appropriate language when browsing web pages where the document contains a language setting.添加语言后,我发现在浏览包含语言设置的文档的网页时,VoiceOver/Safari 组合会自动以适当的语言启动。

After examining various non-English AppStore apps that I have installed, one of them triggers an automatic language change in the screen reader when I open it.在检查了我安装的各种非英语 AppStore 应用程序后,其中一个在我打开屏幕阅读器时会触发自动语言更改。

I experimented with language and localization settings in a very simple iOS app to see if I can trigger such a switch.我在一个非常简单的 iOS 应用程序中尝试了语言和本地化设置,看看我是否可以触发这样的切换。 The app contains a single view controller with a UILabel, created in the storyboard editor.该应用程序包含一个带有 UILabel 的视图控制器,在故事板编辑器中创建。

I tried to change the value of "Localization native development region" in Info.plist.我试图更改 Info.plist 中“本地化本地开发区域”的值。 Swedish is not available on the dropdown in the the graphical editor, so I changed it with "Open as Source Code".瑞典语在图形编辑器的下拉菜单中不可用,因此我将其更改为“作为源代码打开”。 This simply reads the Swedish label as if it were English text, that is, no difference from doing nothing.这只是将瑞典标签读作英文文本,也就是说,与什么都不做没有区别。

Then I tried ahbou's solution of editing project.pbxproj, replacing the references to "en" with "sv".然后我尝试了ahbou编辑 project.pbxproj的解决方案,用“sv”替换对“en”的引用。 I redeployed and with this change, but it makes no difference.我重新部署并进行了此更改,但没有任何区别。

I experimented with adding a second non-English locale, and also with checking and unchecking the "Use base localization" option, but this does not make a difference either.我尝试添加第二个非英语语言环境,以及选中和取消选中“使用基础本地化”选项,但这也没有什么区别。

With all the faffing around, it very briefly did start in Swedish, but after turning the rotor back I was never able to trigger the change again.随着所有的琐碎,它确实以瑞典语开始,但在将转子转回后,我再也无法触发更改。

It occurred to me that there could be a difference between deploying from Xcode and deploying an IPA, so I tried that, no luck.我突然想到从 Xcode 部署和部署 IPA 之间可能存在差异,所以我尝试了这一点,但没有运气。

I tried seeing if I could trigger a VoiceOver language change in a non-minimal app which does not rely on storyboards and which is localised to both English and Swedish.我尝试查看是否可以在不依赖故事板且本地化为英语和瑞典语的非最小应用程序中触发 VoiceOver 语言更改。 If I edit the schema prior to deploying through Xcode, setting "Application Language" to Swedish and "Application Region" to Sweden causes VoiceOver to start in Swedish for the app, but only setting the Application language does not.如果我在通过 Xcode 部署之前编辑架构,将“应用程序语言”设置为瑞典语,将“应用程序区域”设置为瑞典语会导致 VoiceOver 以瑞典语启动应用程序,但仅设置应用程序语言不会。

On looking at the AppStore app I have installed that triggers Swedish speech, it looks like the app might be web content displaying inside a web view.在查看我安装的触发瑞典语语音的 AppStore 应用程序时,看起来该应用程序可能是显示在 Web 视图中的 Web 内容。 Even if that is the case, the fact that it works suggests that there ought to be some way to trigger an automatic switch in a standard iOS app.即使是这种情况,它工作的事实表明应该有某种方法可以触发标准 iOS 应用程序中的自动切换。

Grateful for any ideas!感谢任何想法!

---- Edited Wednesday February 6, 2019 ---- ---- 编辑于 2019 年 2 月 6 日星期三 ----

I experimented with the accessibilityLanguage setting per Mats's helpful suggestion.我根据 Mats 的有用建议尝试了可访问性语言设置。 Setting the language on the UIApplication does propagate it to all elements in the application.在 UIApplication 上设置语言确实会将它传播到应用程序中的所有元素。 I modified the app delegate as follows:我修改了应用程序委托如下:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        application.accessibilityLanguage = "sv"
        return true
    }

Note that the value of isAccessibilityElement is false by default for UIApplication (unlike for the components that users are normally expected to see or interact with).请注意,默认情况下 UIApplication 的isAccessibilityElement值为 false(与用户通常希望看到或与之交互的组件不同)。 It is not necessary to change it to true in order for the language setting to apply, and I'm not sure what the value of changing it would be as users do not interact with the application directly.没有必要将它更改为 true 以便应用语言设置,我不确定更改它的价值是什么,因为用户不直接与应用程序交互。 I did try setting it to true, which does not appear to make any difference as far as VoiceOver is concerned.我确实尝试将其设置为 true,就 VoiceOver 而言,这似乎没有任何区别。

You can change your preferred language by inspecting the Info.plist file (XCode's GUI editor only allows a few languages), once there modify the next property您可以通过检查 Info.plist 文件(XCode 的 GUI 编辑器只允许几种语言)来更改您的首选语言,一旦修改下一个属性

<key>CFBundleLocalizations</key>
<array>
    <string>sp</string>
</array>

Instead of sp (code for Spanish), use the locale code you want use.使用您想要使用的区域设置代码,而不是sp (西班牙语代码)。 I did this and now VoiceOver language is ubiquitous along the app.我这样做了,现在 VoiceOver 语言在应用程序中无处不在。

You can change the VoiceOver language with the accessibilityLanguage property on any accessibility element.您可以使用任何辅助功能元素上的accessibilityLanguage属性更改 VoiceOver 语言。 It is documented in the UIAccessibility additions to NSObject .它记录在UIAccessibility添加到NSObject

I think it also affects all sub-elements, so you should only need to set it for your app window.我认为它也会影响所有子元素,所以你应该只需要为你的应用程序窗口设置它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS辅助功能-如何本地化VoiceOver语言 - iOS accessibility - How to localize VoiceOver language iOS在什么条件下核心蓝牙恢复有效? - iOS Under what conditions Core Bluetooth restoration works? 是否可以在iOS应用中启用或禁用VoiceOver? - Is it possible to enable or disable VoiceOver within an iOS app? Xamarin Forms iOS 中的 ContentPage 的生命周期是什么?为什么当我切换到另一个应用程序时它会崩溃? - What is the life cycle of a ContentPage in Xamarin Forms iOS and why does it crash when I switch to another app? 在什么条件下Metal着色器代码“崩溃?” - Under what conditions does Metal shader code “crash?” iOS 应用程序在 iPad 上使用其他基本语言安装时会自动翻译 - iOS app is translated automatically when installed on iPad with other base language iOS应用程序会自动检查新版本吗? - Does an iOS app automatically check for new versions? 有没有一种方法可以更改iOS应用程序中VoiceOver中默认辅助功能的文本? - Is there a way to change text for default accessibility action in VoiceOver in iOS app? iOS VoiceOver 不读取 UITableview 单元格是否启用 - iOS VoiceOver does not read whether a UITableview cell is enabled or not VoiceOver无法响应锚点并无法正确更改对iOS的关注 - VoiceOver does not react to anchors and changing focus on iOS properly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM