Azure Repos 集成(基于文件)

Azure Repos 集成允许您在 Azure Repos 仓库和 Crowdin 企业版项目之间同步文件。

注意:您需要先在 Crowdin 账户中安装 Azure Repos 集成,然后才能设置和使用它。

在基于文件的项目中,有两种 Azure Repos 集成模式可供选择:

  • 源文件和翻译文件模式 – 在 Azure Repos 仓库和 Crowdin 企业版项目之间同步源文件和翻译文件。
  • 目标文件包模式 – 以所选格式从 Crowdin 企业版项目生成翻译文件并将其推送到您的 Azure Repos 仓库。 在此模式下,集成会推送翻译文件,但不会同步仓库中的源。 如果您在 Crowdin 企业版项目中执行源文本审阅并希望将更新的源文本添加到您的仓库中,您可以将源语言添加为目标语言,该语言将与翻译一起推送到您的仓库中。

在上述任一模式下,所有已翻译和批准的文件都将作为合并请求自动推送到 Azure Repos 仓库中的 l10n 分支。

连接 Azure Repos 账户

  1. 打开您的项目并前往集成
  2. 在“集成”列表中单击 Azure Repos
  3. 单击 设置集成,然后从下拉列表中选择 源文件和翻译文件模式目标文件包模式,以通过您的 Azure Repos 账户进行集成。
  4. 然后在 Azure Repos 端授权与 Crowdin 企业版的连接。

In case the repository you need is private, and you have limited or no access to it, please ask the repository owner to provide you with an access token. 然后,点击 使用个人访问令牌 并将令牌填入 令牌 输入框中,然后点击 Set Up Integration

注意:设置与访问令牌的集成时,请确保您拥有必要仓库的项目管理员级别权限。

选择仓库

在出现的对话框中,选择您的仓库和需要翻译的分支。 建议将重复字符串切换为 在版本分支内显示,这样相同的字符串将被隐藏在分支之间。 如果您的源文件包含具有明显标识符(键)的字符串,最好使用此选项的严格版本。 在其他情况下,请随意使用常规版本。

详细了解重复字符串

目标文件包模式 中使用 Azure Repos 集成时,集成将从您的 Crowdin 企业版项目发送完成的翻译,而无需从您的仓库中提取源文件。 因此,在选择应翻译的仓库和分支时,您可以指定集成应将生成的带有翻译的包放在何处。

详细了解为 VCS 集成配置目标文件包

当您使用私有集成(例如,与自托管 VCS 集成)时,您需要将专用的 Crowdin 企业版 IP 地址添加到白名单中,以确保其正常运行并保持安全。

阅读更多有关 IP 地址 的信息。

服务分支

当翻译完成并且您的语言准备好上线时,Crowdin 企业版会将带有翻译的拉取请求发送到您的版本控制系统。 对于每个进行本地化的分支,Crowdin 企业版都会创建一个带有翻译的附加服务分支。 We don’t commit directly to the master branch so that you can verify translations first.

默认情况下,已在创建的服务分支名称中添加了 l10n_。 If necessary, you can easily change it.

同步配置

要从仓库导入现有翻译,请选择以下选项之一:

  • 分支连接后一次性导入翻译
  • 始终从仓库导入新翻译

默认情况下,选择第一个选项仅导入翻译一次。 或者,如果您不想从仓库导入翻译,则可以清除这两个选项。

By default, sources are not pushed to the repo with translations. 不过,如果您在 Crowdin 企业版项目中执行源文本审查,并希望将对 Crowdin 企业版上的源文件所做的更改推送回您的仓库,请单击编辑,在集成设置中选择推送源,然后单击保存

There are cases when it’s necessary to disable translations from being pushed to the repo temporarily. 在这种情况下,单击 编辑,清除集成设置中的 同步计划,然后单击 保存。 准备好将译文与仓库同步时,选择 同步计划,然后单击 保存

The synchronization is processed every hour automatically. If necessary, you can change the update interval in the integration settings. To configure the synchronization schedule – click Edit, scroll down to the Sync Schedule, set the preferred interval, and click Save.

不依赖于同步设置,源文件在仓库上的更改仍然会持续与 Crowdin 企业版同步。

自动同步分支

设置集成时,您可以选择要添加到 Crowdin 企业版项目的现有仓库分支。 要将未来的分支从 Azure Repos 自动添加到 Crowdin 企业版,请在集成设置中为分支名称创建一个模式。

例如,您在 Azure Repos 集成设置中添加一个模式 *功能。 In this case, the future branches that contain this word at the end of the title will be added to the project.

To add a pattern for branch names, follow these steps:

  1. 单击 Azure Repos 集成部分中的 编辑
  2. 在出现的对话框中,向下滚动到 要自动同步的分支
  3. 要自动同步的分支 字段中,使用通配符选择器(例如“*”、“?”、“[组]”、“\”等)来标识必要的分支。
  4. 单击 保存

默认配置文件名称

crowdin.yml is the default file name that is used for automatically synchronized branches. To change the default settings, click Edit, specify the preferred name in the Default configuration file name field in the integration settings, and click Save.

如果您没有为自动同步的分支指定自定义配置文件名,并且集成在分支的根目录中找不到默认名称为 crowdin.yml 的配置文件,则这些分支将在集成设置中用红色图标标记,并带有感叹号,表示“未准备好。 Check the configuration”.

选择要同步的内容

为了使集成工作,您需要指定应翻译哪些源文件以及 Crowdin 企业版应如何在您的仓库中构建翻译文件。 If you see a red icon with an exclamation mark next to the service branch name, it means that you haven’t selected any content for synchronization.

There are two ways you can specify content for synchronization:

  • Configuring online
  • Configuring manually by creating a configuration file

在线配置

This procedure is the same for all integrations with version control systems (VCS). 查看 VCS 集成:在线配置,了解如何在线选择同步内容。

创建配置文件

配置文件 crowdin.yml 应与您要翻译的每个单独分支一起存储在 Azure Repos 仓库中,以便 Crowdin 企业版知道应该发送哪些文件进行翻译。

它应该具有与 CLI 所需的相同结构,但出于安全原因,项目的凭据不应存储在文件头中。

阅读更多关于 创建配置文件 的信息。

在一个项目中使用多个仓库

如果您正在使用具有适用于不同操作系统版本的多平台产品,则可能需要连接包含每个操作系统源文件的多个仓库。 In this case, localization resources (e.g., TMs, Glossaries) and translations could be used more efficiently, reducing the time needed for project localization.

To add another repository, follow these steps:

  1. 打开您的项目并前往集成
  2. 在“集成”列表中单击 Azure Repos
  3. Click Add Repository.
  4. Configure the integration with the new repository according to your needs and preferences.

检查同步状态

设置集成后,所有相关信息都存储在 集成 > Azure Repos 部分。

集成连接后,只有配置集成的项目成员才能更新设置。 除配置集成的人员外,所有项目管理员都将看到 编辑 按钮被禁用,并在将鼠标悬停在该按钮上时显示以下消息:集成由 {Full Name} 配置

默认情况下,每小时自动进行一次同步。 如果您需要立即启动同步 – 单击 立即同步。 或者,如果您只需要单独同步一个分支,请单击所需分支上的 并选择 同步分支

Azure Repos 立即同步

从仓库中上传译文

默认情况下,存储在仓库中的翻译仅在第一次同步时上传到 Crowdin 企业版。 要手动将译文上传到 Crowdin 企业版,请单击 立即同步 按钮旁边的 ,然后单击 上传译文。 该集成会将现有翻译上传至您的 Crowdin 企业版项目。

Q&A

问:我有一个配置为每次提交都触发的应用程序构建。 由于 Crowdin 在单独的提交中提交每个翻译文件,我如何避免由 Crowdin 的提交触发不必要的应用构建?
答:由于 Crowdin 中的 VCS 集成使用 API 来提交文件而不是 Git,因此每个文件都是单独提交的。

以下是一些可能有助于解决类似情况的建议:

  • 使用 export_languages 选项跳过您还不感兴趣的语言的提交。 详细了解 VCS 集成的导出语言参数
  • 在提交消息中使用 [ci skip] 标签跳过不必要的构建。 详细了解 VCS 集成的提交消息参数
  • 使用 同步计划 配置首选同步间隔(例如每 24 小时设置一次同步)。
  • 合并本地化分支时压缩提交以保持主分支历史记录干净整洁。

另请参阅

本文是否有帮助?