本地化你的 Action
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
由于 Actions 提供对话界面,因此在本地化 Actions 项目时需要考虑的事项比普通开发项目要多。Action 的许多组件都需要翻译,包括设置、资源、intent、类型和提示。
您需要特别注意 Action 的某些组件,以确保对话界面支持目标语言。例如,在创建用于调用意图的训练短语时,应该咨询目标语言的母语者,而不是简单地将使用默认语言创建的短语翻译成目标语言。
Actions Builder 和 Actions SDK 都支持 Action 本地化。将 Actions 项目本地化时,有两组不同的实体需要进行本地化:项目设置/资源和对话组件。
项目设置和资源
项目设置包含用户在 Action 的目录列表中找到的信息,例如 Action 功能的简短说明和详细说明。
资源是指需要本地化的图片、音频文件和其他项目字符串,例如提示中使用的徽标图片或录制的音频。
要本地化项目的设置和资源,只需提供从原始语言区域到新语言区域的翻译版本设置/资源即可。
对话组件
将对话组件本地化不同于仅提供现有内容的翻译。针对其他语言区域将对话本地化的主要目标是提供自然而直观的对话体验;这个概念因语言区域语言的具体情境及其演变而有所不同。
以下部分讨论了将 Actions 项目中的 intent、类型和提示进行本地化的注意事项。
Intent
intent 表示用户希望您的 Action 能够满足的需求。您在 intent 中提供的训练短语有助于 Google 助理的自然语言理解 (NLU) 功能确定 Action 的哪些 intent 与用户请求的内容相匹配。
在对意图进行本地化训练短语时,不应仅翻译现有短语,而应考虑意图的含义并定义能够更好地使用目标语言表达潜在用户请求的训练短语。语言的表现力取决于当地上下文对语言发展的影响以及可用于定义概念的表达式范围。
例如,假设有一个对话互动,在这种互动中,请用户识别他们认为幸运的东西。在巴西,房间角落里可能有一罐盐。在日本,早上看到蜘蛛的用户是幸运的。在中国,看到数字 8 或红色的用户可能会认为自己很幸运。
类型
类型用于定义业务逻辑需要处理的实体。例如,用户订购的商品的选项和修改。使用类型值的同义词,可以让 Google 助理 NLU 更有效地从用户所说的内容中提取信息。即使是简单的 yes
类型值也应该具有 yeah
或 okay
等同义词,因为用户可能会使用其他单词来表示自我肯定话语。
在对类型值的同义词进行本地化时,请务必考虑对于同一概念,不同语言可能会有不同数量的同义词,具体取决于当地语言和文化的发展演变等因素。
举一个例子,帮助说明雪的这个概念。在英语中,有几个表示雪的词,包括“flurry”“blizzard”“slush”和“powder”。相比之下,北欧的萨米语系有 100 多个关于雪的单词。
对假设的类型(如雪)进行本地化时,您应考虑两个点:
- 字词多样:在对话中,Sámi 的发言者希望表达雪的的选项多种多样,而不是说英语。
- 字词特化:给定语言中的某些可用表达式可能过于具体,以致无法用在对话体验中。以萨米语中的“guoldu”一词为例,它表示“在没有风力很大的硬霜时,从地面吹出的一朵雪”。虽然该术语从技术上来说是表示雪类型的一种方式,但对于您的 Action 的讲萨米语的用户来说,它可能没有任何实际用途。
提示
提示用于引导用户与 Action 完成对话。这些信息会告知用户您的 Action 可以执行哪些操作,并要求您提供满足其请求所需的特定信息。
在对提示进行本地化时,请务必考虑不同的语言和文化,对于怎样才算“良好对话”才有不同的预期。
例如,日语有大量用来表现礼貌和正式的语法系统,这可体现出三个主要的礼貌程度:kudaketa(普通形式)、teinei(简单礼貌形式)和 keigo(高级礼让形式)。
选择使用哪种形式取决于多种因素,这些因素决定了每个人在称呼其他人时应使用何种正式程度。对于您的 Action 的日语本地化版本,这意味着两点:
- 了解在称呼用户时应使用哪个级别。
- 根据要求的正式程度提供本地化的提示。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eLocalizing Actions involves translating various components like settings, resources, intents, types, and prompts for a natural conversational experience in the target language.\u003c/p\u003e\n"],["\u003cp\u003eWhen localizing intents and types, consider cultural nuances and linguistic variations to accurately reflect user expressions and entity synonyms in the target language.\u003c/p\u003e\n"],["\u003cp\u003ePrompts should be adapted to align with cultural expectations and conversational norms, such as levels of formality and politeness, for a seamless user experience.\u003c/p\u003e\n"],["\u003cp\u003eEffective localization goes beyond direct translation and requires understanding cultural context and language evolution to ensure the conversation feels intuitive and natural for users in different locales.\u003c/p\u003e\n"]]],["Localizing Actions requires more than simple translation; it involves adapting the conversational experience. Key actions include translating project settings and resources like descriptions and images. Conversational components like intents, types, and prompts need careful consideration of the target language's nuances. Intents require new training phrases crafted with native speaker input. Types need localized synonyms that account for the language's variety and specialization, as seen in different words for snow. Prompts must reflect the target culture's conversational expectations and formality levels.\n"],null,["# Localize your Actions\n\nSince Actions provide a conversational interface, there are more things to\nconsider when localizing an Actions project than an average development project.\nMany components of your Action require translation, including settings,\nresources, intents, types, and prompts.\n\nSome components of an Action require particular attention to ensure that the\nconversational interface works in the target language. For example, training\nphrases used to invoke intents should be created in consultation with native\nspeakers of the target language, rather than simply translating the phrases\ncreated in the default language into the target language.\n\nActions Builder and the Actions SDK both support localization of your Action.\nWhen localizing an Actions project, there are two distinct groups of entities\nthat require localization: project settings/resources and conversational\ncomponents.\n\nProject settings and resources\n------------------------------\n\nA project's settings include the information users find in your Action's\ndirectory listing, like short and long descriptions of your Action's\nfunctionality.\n\nResources are images, audio files, and other project strings that require\nlocalization, like logo images or recorded audio used in prompts.\n\nLocalizing a project's settings and resources is just a matter of providing\ntranslated versions of the settings/resources from the original locale to the\nnew locale.\n\nConversational components\n-------------------------\n\nLocalizing conversational components is different than just providing a\ntranslation of existing content. The main objective of localizing a conversation\nfor other locales is to provide a conversational experience that feels natural\nand intuitive; a concept that varies based on the specific context of the locale\nlanguage and its evolution.\n\nThe following sections discuss considerations for localizing intents, types, and\nprompts in your Actions project.\n\n### Intents\n\nIntents express a user's desire or need that your Action can fulfill. Training\nphrases you provide in an intent help the Assistant's Natural Language\nUnderstanding (NLU) determine which of the Action's intents match what a user is\nrequesting.\n\nWhen you localize training phrases for an intent, instead of just translating\nthe existing phrases, you should consider the meaning of the intent and define\ntraining phrases that better express potential user requests in the target\nlanguage. The expressivity of languages varies based on how the local context\nhas affected the evolution of the language, and the range of expressions\navailable to define concepts.\n\nAs an example, consider a conversational interaction where you ask users to\nidentify something they consider lucky. In Brazil, this could be having a pot of\nsalt in the corner of a room. In Japan, a user who sees a spider in the morning\nis lucky. In China, a user who sees the number 8 or the color red may consider\nthemselves lucky.\n\n### Types\n\nTypes are used to define entities that your business logic needs to handle. For\nexample, options and modifications to items a user is ordering. Synonyms for\ntype values make the Assistant NLU more effective at extracting information from\nwhat a user says. Even a simple `yes` type value should have synonyms like\n`yeah` or `okay`, as a user might use a different word for affirmation.\n\nWhen localizing synonyms for type values, it's important to consider different\nlanguages can have a varying number of synonyms for the same concept, depending\non factors like the evolution of the local language and culture.\n\nAn example that helps clarify this is the concept of snow. In English, there are\na handful of words for snow, including flurry, blizzard, slush, and powder. In\ncontrast, the Sámi family of languages spoken in Northern Europe, has well over\n100 words for snow.\n\nThere are two points that you should consider when localizing a hypothetical\ntype, like snow:\n\n- **Variety of words**: In a conversation, a speaker of Sámi would expect a larger variety of options to express snow, as opposed to an English user.\n- **Specialization of words** : Some available expressions in a given language may be too specific to be useful as part of a conversational experience. For example, consider the Sámi word *guoldu*, which means \"a cloud of snow which blows up from the ground when there is a hard frost without very much wind\". While this term is technically a way to indicate a type of snow, it may not be of any practical use to a Sámi-speaking user of your Action.\n\n### Prompts\n\nPrompts are used to guide users through conversations with your Action. These\ninform the user of what your Action can do, as well as ask for specific\ninformation you need to fulfill their requests.\n\nWhen localizing prompts, it's important to consider different languages and\ncultures can have different expectations about what constitutes a \"good\nconversation\".\n\nFor example, the Japanese language has an extensive grammatical system to\nexpress politeness and formality, that translates to three main politeness\nlevels: *kudaketa* (the plain form), *teinei* (the simple polite form), and\n*keigo* (the advanced polite form).\n\nChoosing which form to use depends on a variety of factors that determine which\nlevel of formality each individual should use when addressing another\nindividual. For the Japanese localization of your Action this means two things:\n\n- Understanding which level to use when addressing your users.\n- Providing localized prompts for the required level(s) of formality."]]