跳转到内容

上下文菜单模块

此模块允许在 Crowdin 的上下文菜单中创建自定义项目。

Crowdin 上下文菜单:

  • 资源 > 翻译记忆 > 翻译记忆记录
  • 资源 > 词汇表 > 词汇表记录
  • 项目主页标签 > 语言记录
  • 项目 > 内容 > 文件 > 文件记录
  • 项目 > 内容 > 截图 > 截图记录
  • 项目 > 语言页面 > 文件记录

Crowdin Enterprise 上下文菜单:

  • 工作区 > 翻译记忆 > 翻译记忆记录
  • 工作区 > 词汇表 > 词汇表记录
  • 项目主页 > 语言记录
  • 项目 > 内容 > 文件 > 文件记录
  • 项目 > 内容 > 截图 > 截图记录
  • 项目主页 > 语言页面 > 文件记录

上下文菜单项目可以打开指定的应用模块,并提供与所选记录相关的额外上下文或自定义 URL。 支持以下类型的操作:

  • 在模态对话框中打开指定的应用模块(参见 模态模块
  • 重定向到指定的应用模块
  • 在新标签页中打开自定义 URL

您可以将此模块的访问权限授予以下用户类别之一:

对于 Crowdin:

  • 仅限我自己(即项目所有者)
  • 我、项目经理和开发人员(如果 location:languagescreenshotsource_filetranslated_file
  • 所有项目成员
  • 选定用户

对于 Crowdin Enterprise:

  • 仅限组织管理员
  • 组织管理员、项目经理和开发人员(如果 location:languagescreenshotsource_filetranslated_file
  • 组织项目中的所有用户
  • 选定用户

上下文菜单项目在模态框中显示指定的模块。

manifest.json
{
"modules": {
"context-menu": [
{
"key": "context-menu-key",
"name": "Name of Context Menu Item",
"description": "Description of Context Menu Item",
"options": {
"location": "source_file",
"type": "modal",
"module": {
"modal": "modal-module-key"
},
"signaturePatterns": {
"fileName": ".*\.json",
"nodeType": [0, 1]
}
}
}
],
"modal": [
{
"key": "modal-module-key",
"name": "New Modal",
"url": "/path/to/integration/module"
}
]
}
}

上下文菜单项目重定向到指定的模块。

manifest.json
{
"modules": {
"context-menu": [
{
"key": "context-menu-key",
"name": "Name of Context Menu Item",
"description": "Description of Context Menu Item",
"options": {
"location": "source_file",
"type": "redirect",
"module": {
"project-integrations": "integration-module-key"
},
"signaturePatterns": {
"fileName": ".*\.json",
"nodeType": [0, 1]
}
}
}
],
"project-integrations": [
{
"key": "integration-module-key",
"name": "New Integration",
"logo": "/integration-logo.png",
"url": "/path/to/integration/module"
}
]
}
}

上下文菜单项目以 URL baseUrl/options.url 打开一个新标签页。

manifest.json
{
"baseUrl": "https://app.example.com",
"modules": {
"context-menu": [
{
"key": "context-menu-key",
"name": "Name of Context Menu Item",
"description": "Description of Context Menu Item",
"options": {
"location": "source_file",
"type": "new_tab",
"url": "/example/path",
"signaturePatterns": {
"fileName": ".*\.json",
"nodeType": [0, 1]
}
}
}
]
}
}
key

类型: string

必填:

描述: Crowdin 应用内的模块标识符。

name

类型: string

必填:

描述: 在上下文菜单中显示的可读名称。

description

类型: string

描述: 对模块功能的可读描述。
该描述将在 Crowdin 界面中显示。

options.location

类型: string

必填:

允许的值: tmglossarystyle_guidelanguagescreenshotsource_filetranslated_file

描述: 在 UI 中可添加上下文菜单的位置。

options.type

类型: string

必填:

允许的值: modalnew_tabredirect

描述: 此模块将执行的操作类型。

options.url

类型: string

描述: 相对 URL。

仅与 new_tab 类型一起使用

options.module

类型: object

描述: 模块定义。

仅与 modalredirect 类型一起使用

signaturePatterns

类型: object

描述: 包含用于检测文件或节点类型的条件,指定何时显示上下文菜单项目。

仅当 options.location 设置为 source_file 时使用

signaturePatterns.fileName

类型: string

描述: 包含用于检测文件类型的 fileName 正则表达式。

signaturePatterns.nodeType

类型: array

允许的值: 0 – 文件夹,1 – 文件,2 – 分支

描述: 节点类型数组,指定上下文菜单项目何时显示。

environments

类型: string

允许值: crowdincrowdin-enterprise

描述: 可安装该模块的环境集合。
此参数在跨产品的应用程序中必需。

本页面对你有帮助吗?