2017-08-11 16:38:18 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2018-02-15 20:37:43 +01:00
|
|
|
import configparser
|
|
|
|
from hashlib import md5
|
2017-08-11 16:38:18 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
import polib
|
|
|
|
|
2018-02-15 20:37:43 +01:00
|
|
|
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
config = configparser.RawConfigParser()
|
|
|
|
config.read(os.path.join(THIS_DIR, '../.transifexrc'))
|
|
|
|
login = '{}:{}'.format(config.get('https://www.transifex.com', 'username'),
|
|
|
|
config.get('https://www.transifex.com', 'password'))
|
|
|
|
|
|
|
|
project_slug = 'zulip-test' # HACK hardcode
|
|
|
|
|
2017-08-11 16:38:18 +02:00
|
|
|
tools_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
root_dir = os.path.dirname(tools_dir)
|
|
|
|
# Choose any translation file for processing all strings.
|
|
|
|
po = polib.pofile(os.path.join(root_dir, 'static', 'locale', 'de', 'LC_MESSAGES', 'django.po'))
|
|
|
|
for entry in po:
|
|
|
|
tag = entry.comment
|
|
|
|
if tag:
|
|
|
|
keys = [entry.msgid, entry.msgctxt or '']
|
|
|
|
msg_hash = md5(':'.join(keys).encode('utf-8')).hexdigest()
|
2018-02-15 20:37:43 +01:00
|
|
|
curl_call = 'curl -i -L --user {} -X PUT -H "Content-Type: application/json" ' \
|
|
|
|
'--data \'{{"tags": ["{}"]}}\' https://www.transifex.com/api/2/project/{}/resource' \
|
|
|
|
'/djangopo/source/{}'.format(login, tag, project_slug, msg_hash)
|
2017-08-11 16:38:18 +02:00
|
|
|
os.system(curl_call)
|