-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmove_translations.py
26 lines (20 loc) · 1.04 KB
/
move_translations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from helpers import read_data, get_settings, package_translation
import api
settings = get_settings()
article_map = read_data('article_map')
locales = ['de', 'es', 'fr', 'ja', 'pt-br']
for article in article_map:
url = '{}/articles/{}/translations/missing.json'.format(settings['src_root'], article)
missing_locales = api.get_resource_list(url, list_name='locales', paginate=False)
for locale in locales:
if locale in missing_locales: # if translation missing in src, nothing to move
continue
print('Moving {} translation for article {}'.format(locale, article))
# get translation in src hc
url = '{}/articles/{}/translations/{}.json'.format(settings['src_root'], article, locale)
translation = api.get_resource(url)
# create translation in dest hc
url = '{}/articles/{}/translations.json'.format(settings['dst_root'], article_map[article])
payload = package_translation(translation)
api.post_resource(url, payload)
print('\nFinished moving translations.\n')