forked from openlp/openlp
Updated some strings to unicode - the rest need to remain strings because web servers don't do unicode that well.
This commit is contained in:
parent
c354d16263
commit
d10358f0a2
@ -181,12 +181,14 @@ def run(command):
|
|||||||
def download_translations():
|
def download_translations():
|
||||||
"""
|
"""
|
||||||
This method downloads the translation files from the Pootle server.
|
This method downloads the translation files from the Pootle server.
|
||||||
|
|
||||||
|
**Note:** URLs and headers need to remain strings, not unicode.
|
||||||
"""
|
"""
|
||||||
global username, password
|
global username, password
|
||||||
if not username:
|
if not username:
|
||||||
username = raw_input('Transifex username: ')
|
username = raw_input(u'Transifex username: ')
|
||||||
if not password:
|
if not password:
|
||||||
password = getpass('Transifex password: ')
|
password = getpass(u'Transifex password: ')
|
||||||
print_quiet(u'Download translation files from Transifex')
|
print_quiet(u'Download translation files from Transifex')
|
||||||
# First get the list of languages
|
# First get the list of languages
|
||||||
url = SERVER_URL + 'resource/ents/'
|
url = SERVER_URL + 'resource/ents/'
|
||||||
@ -195,19 +197,19 @@ def download_translations():
|
|||||||
auth_header = 'Basic %s' % base64string
|
auth_header = 'Basic %s' % base64string
|
||||||
request = urllib2.Request(url + '?details')
|
request = urllib2.Request(url + '?details')
|
||||||
request.add_header('Authorization', auth_header)
|
request.add_header('Authorization', auth_header)
|
||||||
print_verbose('Downloading list of languages from: %s' % url)
|
print_verbose(u'Downloading list of languages from: %s' % url)
|
||||||
json_response = urllib2.urlopen(request)
|
json_response = urllib2.urlopen(request)
|
||||||
json_dict = json.loads(json_response.read())
|
json_dict = json.loads(json_response.read())
|
||||||
languages = [lang['code'] for lang in json_dict['available_languages']]
|
languages = [lang[u'code'] for lang in json_dict[u'available_languages']]
|
||||||
for language in languages:
|
for language in languages:
|
||||||
lang_url = url + 'translation/%s/?file' % language
|
lang_url = url + 'translation/%s/?file' % language
|
||||||
request = urllib2.Request(lang_url)
|
request = urllib2.Request(lang_url)
|
||||||
request.add_header('Authorization', auth_header)
|
request.add_header('Authorization', auth_header)
|
||||||
filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n',
|
filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n',
|
||||||
language + '.ts')
|
language + u'.ts')
|
||||||
print_verbose(u'Get Translation File: %s' % filename)
|
print_verbose(u'Get Translation File: %s' % filename)
|
||||||
response = urllib2.urlopen(request)
|
response = urllib2.urlopen(request)
|
||||||
fd = open(filename, 'w')
|
fd = open(filename, u'w')
|
||||||
fd.write(response.read())
|
fd.write(response.read())
|
||||||
fd.close()
|
fd.close()
|
||||||
print_quiet(u' Done.')
|
print_quiet(u' Done.')
|
||||||
|
Loading…
Reference in New Issue
Block a user