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
|
crowdin_sync.py (Ruby version)
==============================
Introduction
------------
This script is forked and modified from LineageOS and used to synchronize AICP translations with Crowdin. Also, it can handle
automatic commiting to Gerrit and pushing/downloading to/from Crowdin.
Prerequisites
-------------
1. The (depreciated) Ruby variant of crowdin-cli >= 0.5.2 (see: https://github.com/crowdin/crowdin-cli) is required for this to work.
The following commands will install Ruby and the crowdin-cli version on your system:
<code>\curl -sSL https://get.rvm.io | bash -s stable --ruby</code>
<code>source /home/your_username/.rvm/scripts/rvm #Add this to your ~/.bashrc file</code>
<code>rvm all do gem install crowdin-cli</code>
2. Gitpython is used for Git integration and must be installed (also see: http://gitpython.readthedocs.io/en/stable/intro.html).
3. Copy <code>/config/AICP_version_extra_packages.xml</code> 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.
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!
* /n7.1
* /.repo
* /local_manifests/n7.1_extra_packages.xml
* /o8.0
* /.repo
* /local_manifests/o8.0_extra_packages.xml
* crowdin_sync.py
Enviroment variables to export:
export AICP_CROWDIN_API_KEY=aicp_api_key
export AICP_CROWDIN_BASE_PATH=your_base_path
Example:
export AICP_CROWDIN_API_KEY=54e01e81--your-api-key--f6a2724a #Can be found in your project settings page!
export AICP_CROWDIN_BASE_PATH=~/aicp
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] </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>usage: crowdin_sync.py [-h] -u USERNAME -b BRANCH [-c CONFIG]
[--upload-sources] [--upload-translations] [--download]
Synchronising AICP translations with Crowdin
optional arguments:
-h, --help show this help message and exit
-u USERNAME, --username USERNAME
Gerrit username
-b BRANCH, --branch BRANCH
AICP branch
-c CONFIG, --config CONFIG
Custom yaml config
--upload-sources Upload sources to AICP Crowdin
--upload-translations
Upload AICP translations to Crowdin
--download Download AICP translations from Crowdin</pre>
Examples:
<code>./crowdin_sync.py --username GerritName --branch n7.1 --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 n7.1 --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 n7.1 --download</code>
Will download translations from Crowdin of the specified branch (n7.1), based on YAML-config, to your local sources, delete empty translations and
upload updated or new translations to Gerrit for review.
Bugs in the script
------------------
- When committing fails, the reason of it cannot be determined. Often this is just when there
are no new translations, so the script will not exit when this happens or just display
"Finished! Nothing to do or commit anymore." or display error messages in the terminal!
Submitting changes
------------------
The "aicp-crowdin" repository is preconfigured to use the git-review plugin.
More information about git-review can be found at:
https://www.mediawiki.org/wiki/Gerrit/git-review
You can upload your change to the repo's master branch on AICP's Gerrit with commands like these:
git add *
git commit
git review
|