Adjust pull_locales paths

This commit is contained in:
Rob Garrison 2017-07-13 19:50:24 -05:00
parent c97151edf3
commit f49747e1bd
2 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,7 @@ project = transifex.project(project_slug)
project.languages.each do |language| project.languages.each do |language|
code = language.language_code code = language.language_code
puts "Getting locale #{code}" puts "Getting locale #{code}"
dir_name = "_locales/#{code}" dir_name = "../_locales/#{code}"
Dir.mkdir(dir_name) if !Dir.exist?(dir_name) Dir.mkdir(dir_name) if !Dir.exist?(dir_name)
has_content = false has_content = false
project.resources.each do |resource| project.resources.each do |resource|

View File

@ -2,19 +2,19 @@
import io, os, json, re import io, os, json, re
from collections import OrderedDict from collections import OrderedDict
with io.open('/_locales/en/messages.json', 'r', encoding='utf-8') as f: with io.open('../_locales/en/messages.json', 'r', encoding='utf-8') as f:
items = json.load(f).items() items = json.load(f).items()
english = [(k, v['message']) for k, v in items if 'message' in v] english = [(k, v['message']) for k, v in items if 'message' in v]
english_placeholders = [(k, v['placeholders']) for k,v in items english_placeholders = [(k, v['placeholders']) for k,v in items
if 'placeholders' in v] if 'placeholders' in v]
for locale_name in os.listdir('_locales'): for locale_name in os.listdir('../_locales'):
if locale_name == 'en': if locale_name == 'en':
continue continue
if not re.match(r'^\w{2}(_\w{2,3})?$', locale_name): if not re.match(r'^\w{2}(_\w{2,3})?$', locale_name):
print('Skipped %s: not a locale dir' % locale_name) print('Skipped %s: not a locale dir' % locale_name)
continue continue
loc_path = '/_locales/' + locale_name + '/messages.json' loc_path = '../_locales/' + locale_name + '/messages.json'
with io.open(loc_path, 'r+', encoding='utf-8') as f: with io.open(loc_path, 'r+', encoding='utf-8') as f:
loc = json.load(f, object_pairs_hook=OrderedDict) loc = json.load(f, object_pairs_hook=OrderedDict)