aboutsummaryrefslogtreecommitdiff
path: root/README.mkdn
blob: 607f3d10befe7d151e84adb29796e53954258593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
crowdin_sync.py
==============

Introduction
------------
This script is forked and modified from Cyanogenmod/LineageOS and CarbonROM. It is used to synchronize AICP translations with Crowdin.
It can handle automatic commiting to Gerrit, submitting open commits on Gerrit as well as pushing/downloading to/from Crowdin.


Prerequisites
-------------
1. Python version 2.7.x is needed to execute this script (as it is necessary for building the sources anyway).

2. The package "python-lxml" is used for removing empty or faulty translations after download. So it needs to be installed on the system. (also see: https://lxml.de/)

3. The package "python-yaml" must be installed as it is used for parsing the YAML configuration files for determining which files to push.

4. The package "python-git" is used for Git integration and must be installed (also see: https://gitpython.readthedocs.io/en/stable/).

5. The prebuilt java version of crowdin-cli >= 2.0.x (see: https://support.crowdin.com/cli-tool/) is required for this to work.
   It can be download from here: https://downloads.crowdin.com/cli/v2/crowdin-cli.zip

   Follow the installation instructions on the web page and set up the cli-tool correctly.

   *Note: The current limitation is that the JAR-file must be accessible via the path "/usr/local/bin/". You can of course change that in the python script file.*

6. Currently the crowdin-cli tool requires either Linux or macOS and an appropiate Java version >= 1.8.xx to work.

7. <code>/config/AICP-version_extra_packages.xml</code> must be copied to <code>.repo/local_manifests</code> of each "AICP-version" tree.
   This makes sure you will sync all the extra packages not included in the main manifest.
   Please remember that you should comment out the packages you already have in your local aicp_manifest.xml file
   as these are device dependent.


Executing
---------
Export the needed environment variables to set the API key and the base path to your **.bashrc** or **.bash-profile**.
The base path should contain all AICP trees in subfolders, named after AICP branches.

Needed directory structure:

* /home
* /your_username
 * /aicp
   * /config/.yaml  #all YAML config files go in here!
   * /p9.0
     * /.repo
       * /local_manifests/p9.0_extra_packages.xml
   * crowdin_sync.py

Enviroment variables to export:

    export AICP_CROWDIN_API_KEY=aicp_api_key
    export AICP_CROWDIN_BASE_PATH_p9_0=your_base_path_and_branch

Example:

    export AICP_CROWDIN_API_KEY=54e01e81--your-api-key--f6a2724a  #Can be found in your project settings page!
    export AICP_CROWDIN_BASE_PATH_p9_0=/home/your_username/aicp/p9.0  #This is dependent on the real path to your source tree

Execute:
The python script "crowdin_sync.py" and the "config" directory should be copied into the base folder structure, e.g. /home/your_username/aicp, like shown above.

<code>./crowdin_sync.py --username your_gerrit_username --branch AICP_version [--upload-sources] [--upload-translations] [--download] [--local-download] [--submit]</code>

The script incorporates also a little help that can be invoked by executing:

<code>./crowdin_sync.py --help</code>

It will display the following:

<pre><code>usage: crowdin_sync.py [--help] --username USERNAME --branch BRANCH [--config CONFIG] [--upload-sources] [--upload-translations] [--download] [--local-download] [--submit]<br />
<br />
Synchronising AICP translations with Crowdin<br />
<br />
optional arguments:<br />
--help                             show this help message and exit<br />
--username USERNAME                Gerrit username<br />
--branch BRANCH                    AICP branch<br />
-c CONFIG, --config CONFIG         Custom yaml config file to use<br />
--upload-sources                   Upload sources to AICP Crowdin<br />
--upload-translations              Upload AICP translations to Crowdin<br />
--download                         Download AICP translations from Crowdin<br />
--local-download                   Local download AICP translations from Crowdin to PC<br />
--submit                           Merge open AICP translations on GerritName<br /></code></pre>

Examples:

<code>./crowdin_sync.py --username GerritName --branch p9.0 --upload-sources</code>

Will upload specified local files from the YAML-config to Crowdin. Translations already there will be preserved.

<code>./crowdin_sync.py --username GerritName --branch p9.0 --upload-translations</code>

Will upload local translations to Crowdin, based on YAML-config and from your local sources.

<code>./crowdin_sync.py --username GerritName --branch p9.0 --download</code>

Will download translations from Crowdin of the specified branch (p9.0), based on YAML-config, to your local sources,
delete empty translations and upload updated or new translations to AICP Gerrit for review.

<code>./crowdin_sync.py -username GerritName --branch p9.0 --local-download</code>

Will download translations from Crowdin of the specified branch (p9.0), based on YAML-config, to your local sources
and delete empty translations. This is useful to perform local builds and test the imported translations.

<code>./crowdin_sync.py -username GerritName --branch p9.0 --submit</code>

Will search for open translations commits on AICP's Gerrit on the specified branch (p9.0) and
automatically review, verify and submit them into the repositories. This is useful after successful builds and requires
Gerrit Admin rights to preform this action.


Notes:
------
 - The script and the crowdin-cli JAR file provide some output that make the actions performed show up
   in the terminal, so you can follow the execution of the commands.
 - The crowdin JAR file will display a message in the terminal, if it is outdated and found a
   newer version available for download. This is not an error, just a reminder for you!
 - When committing a translation fails, the reason of it cannot be determined everytime. The script will
   simply display the message "Nothing to commit" or an error message mentioning the specific file/commit.
   The script will continue when this happens and display "Finished! Nothing to do or commit anymore.".