GitLab Integration

 

GitLab & Localizely

Introduction

Use this integration to synchronize translation files between your GitLab repository and your Localizely project.

Once you configure the integration, you can pull the files from GitLab by using the Localizely web console. Pull can be automated via webhooks so it is triggered whenever new code changes are pushed to GitLab by your development team.

When the translations are done, you can push the translations to GitLab by creating a pull request.

Setup

1. Create localizely.yml file

GitLab integration relies on the localizely.yml configuration file in your GitLab repository, so Localizely knows what files to synchronize. This file defines which files you want to import (pull) from and export (push) to GitLab.

Here is a minimal configuration file for Flutter projects:

config_version: 1.0 # Only 1.0 available
project_id: c776c33e-f428-4c91-87e1-a6a18c1554fe # Your project ID from: https://app.localizely.com/projects
file_type: flutter_arb
upload:
  files: # List of files for upload to Localizely. Usually it is just one file used for the main locale
    - file: lib/l10n/intl_en.arb
      locale_code: en
download:
  files: # List of files for download from Localizely.
    - file: lib/l10n/intl_en.arb
      locale_code: en
    - file: lib/l10n/intl_de.arb
      locale_code: de
    - file: lib/l10n/intl_es.arb
      locale_code: es

See the documentation to learn more about how to set up your Localizely configuration file.

2. Create GitLab access token

You will need to generate and copy/paste a personal access token from GitLab. Navigate to gitlab.com, click on your avatar in the top right corner and choose Preferences > Access Tokens. Name the token and make sure the access token has the api scope. Then click Create personal access token.

Alternatively, you can create an access token just for your project, if your GitLab plan allows that.

Copy the access token.

3. Connect your repository

Go to the settings for the Localizely project and select GitLab Integration under the Integrations section.

  • Paste your GitLab access token you previously created.
  • Choose the GitLab repository you want to sync with Localizely.
  • Choose the repository branch you want to import (pull) from and export (push) to. Usually, this is the “main” branch.
  • Click Validate Configuration to check if your access token and configuration file are set up correctly.
  • Click Save.
GitLab configuration dialog

Your access token is safe, it is stored in an encrypted form in our system.

Pulling files from GitLab

Manual Pull

Go to Project Settings > Integrations > GitLab, and click the Pull now button.

GitLab configuration details

Auto-Pull

Once you make Pull works, it is practical to set up a webhook in GitLab which automates pulling the changes to Localizely as you push code changes to GitLab.

In GitLab, navigate to your repository Settings > Webhooks and copy/paste the Webhook payload URL and Webhook secret provided in the Localizely integration configuration.

GitLab webhook setup

Pushing files to GitLab

When the translations are completed, go to Project Settings > Integrations > GitLab, and click the Push now button.

The Push will do the following:

  1. A new branch is created from the last revision of the branch you chose in the integration setup. The branch name would look like this: localizely_2021-07-08_13-15-10.
  2. A commit with updated translation files is created in the new branch.
  3. A merge request from the new branch to the previously chosen branch is created.

You may then review and merge the merge request at GitLab.

Frequently Asked Questions (FAQ)

How to link Localizely project to multiple git repositories?

One Localizely project can be directly linked to one GitLab repository via this integration. However, you can use other integrations such as CLI or REST API to link with additional repositories.

Tired of manually editing translation files?

Our platform streamlines software localization for you.

Copyrights 2024 © Localizely