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.
-
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:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
source /home/your_username/.rvm/scripts/rvm #Add this to your ~/.bashrc file
rvm all do gem install crowdin-cli
-
Gitpython is used for Git integration and must be installed (also see: http://gitpython.readthedocs.io/en/stable/intro.html).
-
Copy
/config/AICP_version_extra_packages.xml
to.repo/local_manifests
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.
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
- /.repo
- /o8.0
- /.repo
- /local_manifests/o8.0_extra_packages.xml
- /.repo
- crowdin_sync.py
- /aicp
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)
./crowdin_sync.py --username your_gerrit_username --branch AICP_version [--upload-sources] [--upload-translations] [--download]
The script incorporates also a little help that can be invoked by executing:
./crowdin_sync.py --help
It will display the following:
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
Examples:
./crowdin_sync.py --username GerritName --branch n7.1 --upload-sources
Will upload specified local files from the YAML-config to Crowdin. Translations already there will be preserved.
./crowdin_sync.py --username GerritName --branch n7.1 --upload-translations
Will upload local translations to Crowdin, based on YAML-config and from your local sources.
./crowdin_sync.py --username GerritName --branch n7.1 --download
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.
- 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!
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