mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
translation: Make new tagmessages script a bit easier to run.
Now executable! Just run `tools/tagmessages`. Also, get the username and password from a `.transifexrc` file. And hardcode the project slug to `zulip-test` rather than to `zulip`; the Transifex API is bad at namespacing, so this makes it possible to run this script on a test project (the only way we're currently using it) even for people like me who can also upload to the real Zulip project on Transifex.
This commit is contained in:
19
tools/tagmessages
Normal file → Executable file
19
tools/tagmessages
Normal file → Executable file
@@ -2,13 +2,20 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
from hashlib import md5
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from hashlib import md5
|
|
||||||
import polib
|
import polib
|
||||||
|
|
||||||
username = 'transifex_username'
|
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||||
password = 'transifex_password'
|
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
|
||||||
|
|
||||||
tools_dir = os.path.dirname(os.path.abspath(__file__))
|
tools_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
root_dir = os.path.dirname(tools_dir)
|
root_dir = os.path.dirname(tools_dir)
|
||||||
# Choose any translation file for processing all strings.
|
# Choose any translation file for processing all strings.
|
||||||
@@ -18,7 +25,7 @@ for entry in po:
|
|||||||
if tag:
|
if tag:
|
||||||
keys = [entry.msgid, entry.msgctxt or '']
|
keys = [entry.msgid, entry.msgctxt or '']
|
||||||
msg_hash = md5(':'.join(keys).encode('utf-8')).hexdigest()
|
msg_hash = md5(':'.join(keys).encode('utf-8')).hexdigest()
|
||||||
curl_call = 'curl -i -L --user {}:{} -X PUT -H "Content-Type: application/json" ' \
|
curl_call = 'curl -i -L --user {} -X PUT -H "Content-Type: application/json" ' \
|
||||||
'--data \'{{"tags": ["{}"]}}\' https://www.transifex.com/api/2/project/zulip/resource' \
|
'--data \'{{"tags": ["{}"]}}\' https://www.transifex.com/api/2/project/{}/resource' \
|
||||||
'/djangopo/source/{}'.format(username, password, tag, msg_hash)
|
'/djangopo/source/{}'.format(login, tag, project_slug, msg_hash)
|
||||||
os.system(curl_call)
|
os.system(curl_call)
|
||||||
|
|||||||
Reference in New Issue
Block a user