GitHub Actions

With the github action, you can easily translate your code by just pushing your code to the repository, the github action will then translate your new keys, either create a pull request or commit your changes. This saves you a lot of time and effort while maintaining high quality translations.


Installation

To use the Languine GitHub Action in your repository, you'll need to:

  1. Set up your repository secrets with your Languine credentials
  2. Create a workflow file in your repository

Setting up Repository Secrets

Add the following secrets in your repository settings (Settings > Secrets and variables > Actions):

  • LANGUINE_API_KEY: Your Languine API key
  • LANGUINE_PROJECT_ID: Your Languine project ID

You can find these values in your Languine dashboard under Project Settings.

Environment Variables

The GitHub Action uses the following environment variables:

  • LANGUINE_API_KEY (Required): Your Languine API key for authentication
  • LANGUINE_PROJECT_ID (Required): Your Languine project ID
  • GITHUB_TOKEN (Required): Automatically provided by GitHub, used for creating PRs

Example Workflow

Create a new file .github/workflows/languine.yml in your repository with the following content:

.github/workflows/release.yml
name: Deploy Website

on:
  push:
    branches:
      - '**'
    paths:
      - apps/web/**

jobs:
  translate:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      
      - name: Languine Action
        uses: languine-ai/languine@v1
        env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          api-key: ${{ secrets.LANGUINE_API_KEY }}
          project-id: ${{ secrets.LANGUINE_PROJECT_ID }}

This workflow will:

  • Run on pushes to the main branch
  • Run on pull requests to the main branch
  • Can be triggered manually from the Actions tab
  • Checkout your code and run the Languine translation process
  • Create a pull request with any new translations (configurable)

Working Directory Option

The working-directory option allows you to specify where your translation files are located. This is particularly useful in monorepos where your translations may be in a specific package or app directory. For example:

Pull Request Option (coming soon)

The create-pull-request option controls whether the action creates a pull request with the changes or commits them directly to the branch:

.github/workflows/languine.yml
with:
  create-pull-request: true # create a pull request with the changes

When set to true, the action will:

  • Create a new branch with the changes
  • Create a pull request for review
  • Add appropriate labels and description

When set to false (default), the action will:

  • Commit the changes directly to the current branch
  • Push the changes without creating a pull request

Using with Vercel

If you're using Vercel for deployments, you can combine this GitHub Action with our Vercel build validation to ensure your translations are always synchronized before deployment. This prevents deployments with missing or outdated translations.