## Requirements

To be able to use the translations sync between ps_mbo module and Crowdin, you must use direct branches to the git repository and not a fork.

This restriction is due to git secrets management which disable the usage of public repository secrets by a fork, for security reasons.

## How to translate ?

The translated strings must use translation domains like ```Modules.Mbo.XXX``` as described in the [PS devdocs][dev-docs-translating-modules]

The way to declare strings to translate will be

- PHP

```
$this->trans('My module message', [], 'Modules.Mymodule.Something');
```

- TWIG

```
{{ 'My module message'|trans({}, 'Modules.Mymodule.Something') }}

```

- SMARTY

```
{l s='My module message' d='Modules.Mymodule.Something'}

```

## Process

Let's say I have a feature to develop with translations

I create my branch (FEATURE_BRANCH) based for example on 4.4.x

Once the development finished, I open my Pull Request with 4.4.x as base branch

I add the label `translations_update`

A git action is automatically triggered anytime a PR is labelled translations_update

#### Step 1 :

The [module-translation-tool][module-translation-tool] is used to extract the messages catalogue.

This tool requires all the credentials to clone the git project and submit a PR.

It requires also the branch on which it will work : the FEATURE_BRANCH

Messages are extracted on a separate branch and a PR will be submitted with FEATURE_BRANCH as base

#### Step 2 :

It's time to review the extracted catalogue and be sure it's compliant with the ones I developped.

I'm free to edit the PR if needed. Note that the strings are untranslated in all languages.

Once the PR is clean, I merge it into my FEATURE_BRANCH.

#### Step 3 :

There is a sync process configured in Crowdin to retrieve all the new translations in declared branches and import them to Crowdin.

It's the case of 4.4.x in our example.

Once my PR for FEATURE_BRANCH is merged to 4.4.x, that sync will take place and the new strings are visible into Crowdin

The messages imported as source are the ones in `translations/en-US/*.en-US.xlf`

#### Step 4 :

The translations are made on Crowdin by contributors and our MBO Product team.

Once those new translations are made, a PR is generated by Crowdin and appears on github with the title `New Crowdin updates`.
It contains the translations in all the languages available for the project.

You'll find them in files like `translations/fr-FR/*fr-FR.xlf`

The MBO dev team will review this PR and merge it to the project before the release.

Note that the translations made directly in the project's xlf files will be imported as they are on Crowdin.


[dev-docs-translating-modules]: https://devdocs.prestashop-project.org/8/modules/creation/module-translation/new-system/#translation-domain
[module-translation-tool]: https://github.com/PrestaShopCorp/module-translation-tool