diff options
author | Kevin Goos <kevingoos@telenet.be> | 2018-03-14 15:04:57 +0100 |
---|---|---|
committer | Kevin Goos <kevingoos@telenet.be> | 2018-03-14 15:06:52 +0100 |
commit | 82eace30ab2bd8742301519e6157c8ef238f4885 (patch) | |
tree | 5151dea3b4d7e62fd2fa9a8dbc7feb3548aaa3fc /tools/translate.py | |
parent | 0c5fa5cc8ea437db3c449b158310c5783aaea3ef (diff) | |
download | trackermap-server-82eace30ab2bd8742301519e6157c8ef238f4885.tar.gz trackermap-server-82eace30ab2bd8742301519e6157c8ef238f4885.tar.bz2 trackermap-server-82eace30ab2bd8742301519e6157c8ef238f4885.zip |
Working on laipac2
Diffstat (limited to 'tools/translate.py')
-rw-r--r-- | tools/translate.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/translate.py b/tools/translate.py new file mode 100644 index 000000000..e8324a61a --- /dev/null +++ b/tools/translate.py @@ -0,0 +1,35 @@ +#!/usr/bin/python + +import os +import optparse +import urllib2 +import json +import base64 + +parser = optparse.OptionParser() +parser.add_option("-u", "--user", dest="username", help="transifex user login") +parser.add_option("-p", "--password", dest="password", help="transifex user password") + +(options, args) = parser.parse_args() + +if not options.username or not options.password: + parser.error('User name and password are required') + +os.chdir(os.path.dirname(os.path.abspath(__file__))) + +path = "../web/l10n/" + +def request(url): + req = urllib2.Request(url) + auth = base64.encodestring("%s:%s" % (options.username, options.password)).replace("\n", "") + req.add_header("Authorization", "Basic %s" % auth) + return urllib2.urlopen(req) + +resource = json.load(request("https://www.transifex.com/api/2/project/traccar/resource/web/?details")) + +for language in resource["available_languages"]: + code = language["code"] + data = request("https://www.transifex.com/api/2/project/traccar/resource/web/translation/" + code + "?file") + file = open(path + code + ".json", "wb") + file.write(data.read()) + file.close() |