本地化自定义SiriKit意向 [英] Localizing custom SiriKit intent

查看:93
本文介绍了本地化自定义SiriKit意向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Xcode是v10,我正在针对iOS 12开发SiriKit的自定义意图.

在Xcode 10中,自定义意图是在.intentdefinition文件中设计的,您可以在其中定义意图短语的参数以及意图的标题和该意图的Siri快捷方式.使用.intentdefinition文件构建项目后,Xcode会自动为此意图生成INIntent派生类.

我的问题是,为了支持英语以外的其他语言,以便在系统的常规> Siri& Siri中显示意图的标题.在用户能够操纵自定义意图的快捷方式时进行搜索,我需要为我的.intentdefinition文件提供本地化的意图标题.

当我尝试在File Inspector中为.intentdefinition文件添加另一种语言,然后构建项目时,我得到:

<代码>任务上的重复输出文件'/Users/.../IntentDefinitionGenerated/Intents/MyCustomIntent.swift':IntentDefinitionCodegen/Users/.../ru.lproj/Intents.intentdefinition

这很可能发生,因为Xcode在 .lproj 文件夹中看到多个.intentdefinition文件,并尝试为每个文件夹生成相同的命名类.

如何为iOS 12本地化.intentdefinition文件?

解决方案

转到 intentdefinition 文件-> 文件检查器-> 选择本地化->现在,为您的 intentdefinition 文件选择当前语言.这会将您现有的 intentdefinition 文件转换为当前语言.

现在再次选择相同的 intentdefinition 文件,添加其他语言->它将创建一个新的 Intents.strings 文件,您可以在其中自定义其他语言环境的文本./p>

My Xcode is v10 and I'm developing a custom intent for SiriKit, targeting iOS 12.

In Xcode 10, custom intents are designed in .intentdefinition files, where you can define your own parameters for intent phrases as well as the title of the intent and Siri shortcut for that intent. Building a project with a .intentdefinition file makes Xcode automatically generate an INIntent derived class for that intent.

My issue is that in order to support other languages than English so that the intent's title is show in the system's language in General > Siri & Search when the user is able to manipulate shortcuts for custom intents, I need to provide localized intent title for my .intentdefinition file.

When I try to add another language for my .intentdefinition file in the File Inspector and then build the project I get:

duplicate output file '/Users/.../IntentDefinitionGenerated/Intents/MyCustomIntent.swift' on task: IntentDefinitionCodegen /Users/.../ru.lproj/Intents.intentdefinition

This is likely happening because Xcode sees multiple .intentdefinition files in .lproj folders and tries to generate a same named class for each of them.

How do I localize my .intentdefinition file for iOS 12?

解决方案

Go to intentdefinition file -> File Inspector -> Select Localize -> Now select current language for your intentdefinition file. This will convert your existing intentdefinition file for current language.

Now again select the same intentdefinitionfile, add other language -> it will create a new Intents.strings file where you can customize the text for other locales.

这篇关于本地化自定义SiriKit意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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