Bitbucket 集成(基于文件)

Bitbucket 集成允许您在 Bitbucket 存储库和 Crowdin 项目之间同步文件。

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

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

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

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

连接 Bitbucket 账户

  1. 打开您的项目并前往集成选项卡。
  2. 在集成列表中单击 Bitbucket
  3. 点击设置集成,然后从下拉列表中选择源文件和翻译文件模式目标文件包模式,以通过您的 Bitbucket 帐户进行集成。 Bitbucket 集成 连接 Bitbucket
  4. 然后在 Bitbucket 授权与 Crowdin 的连接: Bitbucket Integration Authorization

选择仓库

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

详细了解 重复字符串

Bitbucket 集成未配置

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

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

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

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

服务分支

When translations are finished and your languages are ready to go live, Crowdin sends the pull request with translations to your version control system. For every branch that is under localization, Crowdin creates an additional service branch with translations. We don’t commit directly to the master branch so that you can verify translations first.

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

同步配置

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

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

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

Bitbucket 翻译导入选项

By default, sources are not pushed to the repo with translations. Although, if you perform a source text review in your Crowdin project and would like to push the changes made to your source files on Crowdin back to your repo, click Edit, select Push Sources in the integration settings, and click Save.

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 持续同步。

Bitbucket 同步设置

自动同步分支

When you set up the integration, you select existing repository branches to be added to the Crowdin project. 要将未来的分支从 Bitbucket 自动添加到 Crowdin,请在集成设置中为分支名称创建一个模式。

例如,您在 Bitbucket 集成设置中添加*功能模式。 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. 单击 Bitbucket 集成部分中的编辑
  2. 在出现的对话框中,向下滚动到 要自动同步的分支
  3. 要自动同步的分支 字段中,使用通配符选择器(例如“*”、“?”、“[组]”、“\”等)来标识必要的分支。
  4. 单击 保存Branches to Sync Automatically

默认配置文件名称

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). Check VCS Integrations: Configuring Online to get to know how to select content for synchronization online.

创建配置文件

配置文件 crowdin.yml 应与要翻译的每个独立分支一起保存在 Bitbucket 存储库中,这样 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. 在集成列表中单击 Bitbucket
  3. Click Add Repository.
  4. Configure the integration with the new repository according to your needs and preferences.

Bitbucket 集成多个版本库

检查同步状态

集成设置完成后,所有相关信息都将存储在 集成 标签> Bitbucket 中。

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

默认情况下,每小时自动进行一次同步。 如果您需要立即启动同步 – 单击 立即同步

立即同步 Bitbucket

或者,如果您只需要单独同步一个分支,请在所需分支上单击 ,然后选择 同步分支

Bitbucket 同步分支

从仓库中上传译文

默认情况下,存储在 仓库中的译文仅在第一次同步期间上传到 Crowdin。 要手动将译文上传到 Crowdin,请单击 立即同步 按钮上的下拉切换按钮,然后单击 上传译文。 The integration will upload existing translations to your Crowdin project.

在 Bitbucket 上传翻译

疑问解答

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

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

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

另请参阅

本文是否有帮助?