GitLab app

Updated

The Translatize GitLab app does for gitlab.com what the GitHub App does for GitHub. Every merge request that changes your source strings gets its own translation branch, a Translatize commit status and one summary note with translation status and quality results. Translations can be committed back to the merge request, and the branch is merged into your base branch when the merge request merges. There is no pipeline file to write and no token to store.

What you need

  • A project on the Professional or Agency plan (see Plans).
  • The admin or owner role in the Translatize project.
  • A project on gitlab.com where your GitLab account is at least Developer. To have merge requests reach Translatize, that account should be a Maintainer or Owner (see The webhook). Self-managed GitLab is not supported yet.
  • Translation files in any of the twelve supported formats, described in a translatize.config.json in the repository.

Connect a project

  1. In the app, open the project, then Project Settings → GitLab (in the Developers group). Only admins and owners see this tab.
  2. Under 1. Connect your GitLab account, click Connect GitLab. GitLab opens in a new tab; sign in and allow the app. The projects you can link are read with your own account.
  3. Under 2. Pick a project, choose the GitLab project (the list is good for one hour; connect again if it runs out) and the Base branch – the Translatize branch that merge request branches start from and are merged back into, usually main. Set the options described under Settings and click Link project.
  4. Commit a translatize.config.json to the root of the repository. The tab shows one with your project id filled in, with a Copy button. Merge requests whose branch contains the file are processed from then on.
translatize.config.json
{
  "projectId": "your-project-id",
  "format": "json-nested",
  "files": "locales/{lang}.json",
  "gitlab": {
    "autoTranslate": true,
    "commitTranslations": "on-request",
    "requireComplete": false,
    "syncDefaultBranch": true
  }
}

It is the same file the CLI and the GitHub App read, with every field described on the GitHub App page. The one difference is the optional block: on GitLab it is called gitlab, with the same keys as github. A key there overrides the matching setting in the tab for this repository. As on GitHub, a merge request can turn autoTranslate and commitTranslations down for itself at once, but not up: a value that would translate or commit more than the target branch allows applies once the change is merged, and the note says so.

Merge requests already open

Linking runs no bulk sync. It adds the webhook and nothing else, so it spends no AI translation characters and posts no notes. A merge request that is already open starts at its next push, or when it is reopened.

The app works as the account that connected it
The app reads and writes GitLab with the access of the person who connected it, so use an account that will stay on the project. Commits the app makes show as that person's, and GitLab's rate limits count against them. If that person leaves, use Connect with another GitLab account; the new account needs Developer access or above. The connection also creates an API token for the app, listed under Project Settings → Integrations with a GitLab app badge and renewed or revoked in the GitLab tab. Linking, changing and disconnecting are recorded in the audit log.

One repository host per project

A project syncs with one repository host at a time: the GitHub App or the GitLab app, not both. Both would write to the same Translatize branches and overwrite each other. If the project already uses the GitHub App, the GitLab tab says so and links to it; disconnect that first. The same is true the other way round. A Translatize project links one GitLab project, and a GitLab project links to one Translatize project.

The webhook

Linking adds a webhook to the GitLab project, so that merge requests, comments and pushes reach Translatize. GitLab only lets Maintainers and Owners add webhooks.

A Developer can link the project, and the tab warns about this before you do. If GitLab then refuses the webhook, the link exists but merge requests do not reach Translatize, and the tab says so. A Maintainer fixes it with Reconnect with a Maintainer account. If the webhook could not be added for another reason, Try again retries it. The tab reads your access as GitLab lists it; access through a shared group may show as Developer even when you are a Maintainer, and the webhook is still tried.

What happens on a merge request

When a merge request from a branch of the project is opened, reopened or gets new commits, the app does this (for a fork, see Forks):

  1. Compares the source file. It reads the config and the source-language file at the merge request's latest commit and compares it with the commit the merge request branched off. Strings changed on the target branch since then don't count as the merge request's.
  2. Creates the branch. The first time, it creates the Translatize branch mr-7 (for merge request !7) from your base branch; later pushes reuse it. If a branch of that name already exists and the app did not create it, it uses mr-7-2 and so on, and leaves the existing one alone.
  3. Adds the strings that were added or changed, in the source language. Keys removed from the source file are listed but stay in Translatize.
  4. Translates them. With Translate new strings automatically on, the changed strings are AI-translated into every other project language, using the project's monthly AI translation characters. Pushes that do not touch the source file translate nothing. See Forks.
  5. Checks quality. The quality checks run on the changed keys, and the project's merge gate says whether the branch would be allowed to merge.
  6. Reports. It sets the Translatize commit status on the latest commit and creates one summary note on the merge request, which it edits on every later push instead of adding new ones.

A merge request that adds or changes no source string gets a passing status and no note and no branch. Everyone on the project sees an MR !7 badge next to the branch, which links to the merge request.

The status and the summary note

The commit status is named Translatize and links to the branch in Translatize. Its description reads like the GitHub check's title. It fails only on what your project asked to block on; everything else passes, and the description says what is going on:

StatusDescription (examples)When
failed2 QA errors block the mergeThe project merge gate is set to Block, and these errors would stop the merge.
failed4 translations missing"Fail the commit status while translations are missing" is on.
successTranslating 2 changed keys – this status updates when the job finishesAI translation is running.
success2 changed keys – all translatedEvery target language has a value for every changed key.
success2 changed keys – 4 translations missing; QA: 1 error, 2 warningsValues are missing or QA found something, and nothing is set to block on it.
successNo translation changesThe merge request adds or changes no source string.
successA message that Translatize needs attention; or Translations mergedThe connection is paused, something stopped the app from judging, or the merge request has merged.

The summary note shows:

  • how many keys were added and changed, and the source language;
  • a table with Translated and Missing per target language;
  • the QA errors and warnings, and the merge gate mode;
  • how many keys the merge request removed;
  • a link to open the branch in Translatize, and the changed keys and any notes under Details.
Pipelines must succeed
A commit status joins the commit's pipeline, so its state is your pipeline's. With "Pipelines must succeed", a failed Translatize status holds the merge like a required check would – which is why it fails only on a blocking merge gate or on missing translations you asked to fail on. The app never posts a running, pending, skipped or canceled status, so it never holds a merge while it translates and never cancels a pipeline. It posts a status only when the result changed, so updates add no jobs to your pipeline. A status posted before your CI pipeline started stays in a pipeline of its own until its result changes; the summary note always has the result, and the merge gate is still applied when the merge request merges.

Committing translations back

Translations live on the merge request's Translatize branch. Whether they are also committed to the merge request is your choice, in the tab or as commitTranslations in the config:

SettingWhat happens
On request (on-request, the default)Comment /translatize sync on the merge request.
Automatically (auto)The app commits whenever an AI translation run for the merge request completes.
Never (never)Nothing is committed. Bring translations in with translatize pull or the GitLab CI component.

/translatize sync

GitLab has no check button, so the request is a comment. Write this on a line of its own:

Merge request comment
/translatize sync
  • Only Developer or higher can use it. For anyone else, the summary note says the command was refused.
  • It works on merge requests from a branch of the same project. On a merge request from a fork it commits nothing and answers with a note that the merge request is synced once it is merged.
  • An edited comment, or the command inside other text on a line, is ignored.

The result is one commit on the merge request's branch with the message chore(i18n): sync translations from Translatize, holding one file per target language at your files path, written as translatize pull writes them. Files that would not change are left alone. GitLab shows the commit as made by the person who connected the app. The commit does not start another round.

The files-for-every-language formats (csv, yaml, json, xcstrings) follow the same care as on the GitHub App: the file is only written when no source string would change or disappear.

Settings

SettingConfig keyDefaultWhat it does
Base branch–mainThe Translatize branch merge request branches start from and are merged back into. Open merge requests keep their branches; the next ones use the new base.
Translate new strings automaticallyautoTranslateonAI translates the source strings a merge request adds or changes.
Commit translations to the merge requestcommitTranslationsOn requestSee above. Never for merge requests from forks.
Fail the commit status while translations are missingrequireCompleteoffThe status fails until every target language has a value for each changed key.
Sync pushes to the default branchsyncDefaultBranchonSource strings that reach the default branch without a merge request are written to the base branch. Only the source language; nothing is translated automatically.

Merge requests from forks

A merge request from a fork is not synced. Anyone can open one, so the app reads nothing from it – not even its translatize.config.json – and creates no branch, adds no strings, runs no AI translation and commits nothing. It gets no commit status (GitLab shows a fork's own pipelines) and no note, which would be a comment by the connected account on every fork's merge request. Writing /translatize sync on it gets a note that explains this.

Once it is merged into the default branch, Sync pushes to the default branch brings its source strings into the base branch, in the source language only; translate them there. With that setting off, they reach Translatize only with translatize push. A fork's merge request can't be synced before it merges.

When the merge request merges or closes

When merge request !7 is merged, the app merges mr-7 into the base branch from the tab, then deletes it. As on GitHub, only what the branch added or changed is merged; everything else on the base branch stays, keys removed from the source file are not deleted, and where a key was also edited on the base branch meanwhile, the merge request's value wins and the note lists the keys to look at again. See the GitHub App page for the details.

If the merge gate is set to Block and finds QA errors, nothing is merged: the status fails, the branch is kept and the project's admins and owners get an in-app notification. Fix the errors and merge the branch in Translatize; an admin or owner can also override the gate there with a written reason.

When a merge request is closed without merging, its branch is deleted and nothing is merged. Reopening it starts again with a new branch.

Plans and limits

  • The GitLab app is part of the Professional and Agency plans. What counts is the plan of the account that pays for the project. On Free and Starter the tab explains the app and links to the plans.
  • If the plan drops below Professional, the connection pauses (Paused – plan) and resumes by itself after an upgrade. Open merge requests that already have a Translatize branch are synced again, and those merged or closed in the meantime are then merged or cleaned up. One opened during the pause starts at its next push.
  • Only gitlab.com. The project list shows the 1,000 most recently active projects you can reach.
  • A source or language file over 5 MB is skipped with a note, and the config file may be up to 64 KB.
  • The app calls GitLab as the connected account, so GitLab's per-user rate limits apply to that account. On very busy projects, an event can wait for the next one.
  • The AI translation of a merge request uses the project's monthly characters, like the GitHub App.

Disconnecting

Disconnect project at the bottom of the GitLab tab stops GitLab sync, removes the webhook and revokes the app's access. Branches and translations made so far stay in Translatize, and so do the merge request badges. If GitLab cannot remove the webhook, the tab tells you to delete it by hand under Settings → Webhooks in the GitLab project; it does nothing any more. You can also remove the app under your GitLab account's Applications.

Troubleshooting

You seeWhat to do
No Translatize status or noteOpen the GitLab tab: the project must be linked and Active, and the webhook must be in place.
"The webhook could not be added" / "GitLab lets only Maintainers add webhooks"Reconnect with a Maintainer or Owner account, or press Try again.
Reconnect neededGitLab no longer accepts the connection, or the account lost Developer access. Reconnect with an account that has access.
"Translatize is not set up for this repository"translatize.config.json is missing from the root of the merge request's branch.
A comment with the command had no effectCheck it sits on a line of its own, the merge request is from the same project, and your role is Developer or higher.
No branch, status or note on a merge request from a forkBy design: it is synced once it is merged. See Merge requests from forks.