跳转到内容

应用程序描述符

应用描述符是一个 JSON 文件,通常为 manifest.json,用于告知 Crowdin 该应用是什么以及它添加了哪些模块。

Crowdin 应用集成

应用描述符是一个 JSON 对象。自托管应用从自己的服务器提供它,而无服务器应用将其保留在项目中并通过 CLI 推送到 Crowdin。

manifest.json
{
"identifier": "your-application-identifier",
"name": "Your Application",
"description": "Application description",
"logo": "/assets/logos/app-logo.png",
"baseUrl": "https://example.com",
"authentication": {
"type": "crowdin_app",
"clientId": "your-client-id"
},
"events": {
"installed": "/hooks/installed"
},
"scopes": [
"project"
],
"modules": {
"project-integrations": [
{
"key": "your-module-key",
"name": "Module Name",
"description": "Module description",
"logo": "/assets/logos/module-logo.png",
"url": "/page/integration",
"environments": [
"crowdin", "crowdin-enterprise"
]
}
]
}
}

无服务器描述符没有 baseUrl,声明 UI 模块时不带 url,并省略 events,因为 events 指向你自己服务器上的 URL。

manifest.json
{
"identifier": "your-application-identifier",
"name": "Your Application",
"description": "Application description",
"bundle": {
"mode": "internal"
},
"scopes": [
"project"
],
"modules": {
"project-menu": [
{
"key": "your-module-key",
"name": "Module name"
}
]
}
}
属性描述
identifier

类型: string

必需: 是

描述: 用于标识应用的唯一键,最多 255 个字符。

name

类型: string

必填: 是

描述: 应用的可读名称。

baseUrl

类型: string(uri)

必需: 是(仅自托管应用)

描述: 远程应用的基础 URL,用于所有返回该应用的通信。没有 baseUrl 的描述符描述的是无服务器应用,由 Crowdin 托管和运行。

bundle

类型: object

描述: 仅适用于无服务器应用。 Crowdin 提供应用的位置。对于上传到 Crowdin 的包,将 mode 设置为 internal;或将 mode 设置为 external,并将 url 指向本地开发服务器。

authentication

类型: Authentication

描述: 在 Crowdin 与应用之间签署请求时使用的身份验证类型。默认为 none,这是无服务器应用使用的类型。

description

类型: string

描述: 对应用功能的用户可读描述。它在 Crowdin UI 中可见。

logo

类型: string(relativeUri)

描述: 相对于应用基础 URL 的图片 URL,显示在 Crowdin UI 中。

events

类型: Events

描述: 应用事件通知的回调(仅自托管应用)。

scopes

类型: [string, … ]

必需: 是

描述: 此应用请求的作用域集合。

modules

类型: object

必需: 是

描述: 此应用提供的模块列表。无服务器应用提供 UI 模块。

default_permissions

类型: object

描述: 安装后谁可以立即使用应用。 user 接受 owner、managers、all 或 guests,而 project 接受 own 或 restricted。

stringBasedAvailable

类型: boolean

描述: 应用的模块是否在基于字符串的项目中可用。在基于文件的项目中它们始终可用。

baseUrl 必须以 https:// 开头,并且在应用安装后,如果不先卸载应用,就无法更改,因此在将应用公开之前请先选择好。

清单中的所有其他 URL,例如 logo、events 和模块 URL,都相对于 baseUrl。每个都以 / 开头。 Crowdin 会移除 baseUrl 末尾的 /,因此 https://example.com/ 和 https://example.com 效果相同。

指定 Crowdin 在签署发往应用的请求时使用的身份验证类型:

  • crowdin_app:通过 OAuth 应用。当应用需要自行随时调用 Crowdin API 时使用。
  • none:不使用 OAuth 应用。应用仍可访问 API,但仅在其在用户端运行时,例如其 iframe 打开时。无服务器应用使用此类型。
  • crowdin_agent:通过 Crowdin 在安装应用时创建的专用机器人用户,这样应用之后可以在项目中继续工作,例如在自定义工作流步骤上。应用的 API 调用以该用户身份进行身份验证。工作流步骤类型模块需要此类型。

阅读更多关于 Crowdin 应用安全性的内容。

示例:

manifest.json
{
"authentication": {
"type": "crowdin_app",
"clientId": "your-client-id"
}
}
字段类型描述
typestring要使用的身份验证类型:none(默认)、crowdin_app 或 crowdin_agent。
clientIdstring通过 crowdin_app 类型进行授权的 OAuth 客户端 ID。

模块是应用扩展 Crowdin 的方式。每种类型声明应用在界面中出现的位置或其处理的内容:

  • UI 模块:Crowdin 内的面板、仪表板、菜单和对话框。
  • AI 模块:自定义 AI 提供商、提示提供商和 AI 请求处理器。
  • 文件处理模块:自定义文件格式,以及导入和导出前后的处理。
  • 其他模块:自定义机器翻译引擎、Webhook、工作流步骤、QA 检查和拼写检查器。

阅读更多关于 UI 模块、AI 模块和文件处理模块的内容。

自托管应用为工作区中发生的事件注册回调。此对象中的每个属性都是相对于应用 baseUrl 的 URL,当事件触发时,Crowdin 会向其发送 POST 请求。 installed 回调是安装过程本身的一部分,其余回调的行为类似于 Webhook。

示例:

manifest.json
{
"events": {
"installed": "/hooks/installed",
"uninstall": "/hooks/uninstall"
}
}
事件类型描述
installedstring在用户在 Crowdin 中安装应用后发送给应用。在 crowdin_app 和 crowdin_agent 身份验证类型下为必需。
uninstallstring在应用从 Crowdin 卸载之前发送给应用。

当用户安装应用时,Crowdin 会向应用发送 installed 事件。载荷描述应用安装到的工作区或配置文件、应用本身,以及应用获取 API 令牌所需的凭据。

了解更多关于已安装事件流程的信息。

载荷示例:

{
"appId": "your-application-identifier",
"appSecret": "dbfg....asdffgg",
"clientId": "your-client-id",
"userId": 1,
"organizationId": 1,
"domain": null,
"baseUrl": "https://crowdin.com"
}
{
"appId": "your-application-identifier",
"appSecret": "dbfg....asdffgg",
"clientId": "your-client-id",
"userId": 1,
"organizationId": 1,
"domain": "{domain}",
"baseUrl": "https://{domain}.crowdin.com"
}

参数:

字段类型描述
appIdstring在应用描述符文件中声明的应用标识符。
appSecretstring用于授权你的 Crowdin 应用的唯一密钥。
clientIdstring在应用描述符文件中声明的 OAuth 客户端标识符。
userIdinteger安装应用的用户的数字标识符。
organizationIdinteger应用安装到的组织的数字标识符。
domainstring应用安装到的 Crowdin 企业版组织的名称。在 Crowdin 中该值始终为 null。
baseUrlstring应用安装到的 Crowdin 企业版组织的 baseUrl。在 Crowdin 中该值始终为 https://crowdin.com。
agentIdinteger为应用创建的代理用户的数字标识符。仅针对使用 crowdin_agent 身份验证类型的应用发送。

在应用被移除之前,Crowdin 会向应用发送 uninstall 事件。与 installed 事件类似,载荷描述应用安装到的工作区或账户以及应用本身。使用它来删除你为该工作区或账户存储的数据。

载荷示例:

{
"appId": "your-application-identifier",
"clientId": "your-client-id",
"organizationId": 1,
"domain": null,
"baseUrl": "https://crowdin.com"
}
{
"appId": "your-application-identifier",
"clientId": "your-client-id",
"organizationId": 1,
"domain": "{domain}",
"baseUrl": "https://{domain}.crowdin.com"
}

参数:

字段类型描述
appIdstring在应用描述符文件中声明的应用标识符。
clientIdstring在应用描述符文件中声明的 OAuth 客户端标识符。
organizationIdinteger应用卸载自的组织的数字标识符。
domainstring应用卸载自的 Crowdin 企业版组织的名称。在 Crowdin 中该值始终为 null。
baseUrlstring应用卸载自的 Crowdin Enterprise 组织的 baseUrl。在 Crowdin 中该值始终为 https://crowdin.com。
本页面对你有帮助吗?