检查翻译

如何验证翻译是否存在

简介

根据您的代码仓库配置,贡献者可能会绕过翻译流程,或者翻译流水线可能根本没有被触发。

为了确保生产环境中有可用的翻译,建议在部署流程中运行以下命令:

npx lingo.dev@latest run --frozen

该命令将:

  1. 检查所有预期内容是否已翻译。
  2. 如果有内容未翻译,则以非零状态码退出。

CI/CD 工作流示例

本节演示如何设置最小化的 CI/CD 工作流以检查翻译。

Bitbucket Pipelines

将以下配置复制到 .gitlab-ci.yml 文件中:

check_translations:
  image: node:20-alpine
  script:
    - npx lingo.dev@latest run --frozen

要了解更多关于 Bitbucket Pipelines 的设置,请参阅 Bitbucket Pipelines

GitHub Actions

将以下配置复制到 .github/workflows/check-translations.yml 文件中:

name: Check translations
on: [push, pull_request]
jobs:
  check_translations:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npx lingo.dev@latest run --frozen

要了解更多关于 GitHub Actions 的设置,请参阅 GitHub Actions

GitLab CI/CD

将以下配置复制到 bitbucket-pipelines.yml 文件中:

pipelines:
  check_translations:
    - step:
        image: node:20
        script:
          - npx lingo.dev@latest run --frozen

要了解更多关于 GitLab CI/CD 的设置,请参阅 GitLab CI/CD