Search code examples
reactjsgitlabinternationalizationi18nextweblate

How do I set up Weblate to access a GitLab repository?


I am following the tutorial in the official Weblate documentation weblate documentation. Nevertheless, I am encountering difficulties in enabling the Weblate host to access my GitLab repository for the purpose of pushing to it. Could someone kindly provide guidance on achieving this, either using an SSH key or an access token?

If possible, could you offer a step-by-step example for better understanding? I would greatly appreciate any assistance that could be provided. Thank you sincerely!


Solution

  • There are essentially two methods to grant Weblate access to your GitLab/GitHub repository.

    1. Access via ssh key

    On weblate:

    1. Create a new project (click on + "Add a new translation project").
    2. In your project, go to Manage -> API access -> copy your ssh key

    On Gitlab:

    1. Navigate to your project -> settings -> repository -> Deploy keys -> Add a title, your copied ssh key and grant write permissions to this key

    Back to weblate:

    1. In your project -> Create a component
    2. Fill in all the required inputs...

    Important points: Version control system is Git Source code repository: Your SSH link to your Gitlab like: ssh://git@gitlab... Repository branch: add a branch created in your repository... .

    Click on continue, add file format and both Repository push and push branch, use the same details as the Source code repository and Repository branch.

    2. Access via token

    On Your Gitlab Project Go to repository -> settings -> access tokens Add a token name, role, it should be a developer, and at least read and write permissions. Create the access token As you create the token, a user will be generated for you... Copy the access token.

    Next, go to your repository's Members (Manage -> Members). You will see a new member was created with the name of the token you generated. Copy the weblate name after the @. Also copy the HTTPS address of your repository

    On Weblate:

    Go to the project where you want to grant Gitlab access. Create a component... Follow the same configuration as with SSH. The difference is the Source code repository. You will now need to add the address like: https://copied_weblate_member_user_created_in_gitlab:copied_gitlab_token@gitlab_address_copied...

    Now, for pushing changes from Weblate to Gitlab: Open your weblate project, select a created component, add/edit some translation language. Click at the component again and navigate to Manage -> Repository mainenance and here you can commit and push.

    Best luck!