Skip to content

Commit

Permalink
Merge pull request #23 from flodolo/update_list
Browse files Browse the repository at this point in the history
Bug 1257818 - [l10n] Build tools: add optional parameter with list of locales to update to update-xliff.py
  • Loading branch information
flodolo committed Mar 23, 2016
2 parents 0c3de09 + 548ea12 commit e6998fc
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions scripts/update-xliff.py
Expand Up @@ -50,16 +50,28 @@ def main():

parser = argparse.ArgumentParser()
parser.add_argument('base_folder', help='Path to folder including subfolders for all locales')
parser.add_argument('locales', nargs='*', help='Locales to process')
args = parser.parse_args()

# Get a list of files to update (absolute paths)
base_folder = os.path.realpath(args.base_folder)
file_paths = []
for xliff_path in glob(base_folder + '/*/' + xliff_filename):
parts = xliff_path.split(os.sep)
if not parts[-2] in excluded_locales:
file_paths.append(xliff_path)
file_paths.sort()
if not args.locales:
for xliff_path in glob(base_folder + '/*/' + xliff_filename):
parts = xliff_path.split(os.sep)
if not parts[-2] in excluded_locales:
file_paths.append(xliff_path)
else:
for locale in args.locales:
if os.path.isdir(locale):
file_paths.append(os.path.join(base_folder, locale, xliff_filename))
else:
print 'Requested locale doesn\'t exist:', locale

if not file_paths:
print 'No locales updated.'
else:
file_paths.sort()

for file_path in file_paths:
print 'Updating %s' % file_path
Expand Down

0 comments on commit e6998fc

Please sign in to comment.