-
Notifications
You must be signed in to change notification settings - Fork 23
/
export-xliff.py
executable file
·50 lines (42 loc) · 1.34 KB
/
export-xliff.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
#
# xliff-export.py xcodeproj-path l10n-path
#
# Export all locales that are present in the l10n directory. We use xcodebuild
# to export and write to l10n-directory/$locale/firefox-ios.xliff so that it
# can be easily imported into Git (which is a manual step).
#
# Example:
#
# cd firefox-ios
# ./xliff-export.py Client.xcodeproj ../firefoxios-l10n
#
import glob
import os
import shutil
import subprocess
import sys
LOCALES_TO_SKIP = []
def available_locales(l10n_path):
for xliff_path in glob.glob(l10n_path + "/*/firefox-ios.xliff"):
parts = xliff_path.split(os.sep)
yield parts[-2]
if __name__ == "__main__":
project_path = sys.argv[1]
l10n_path = sys.argv[2]
for locale in available_locales(l10n_path):
if locale in LOCALES_TO_SKIP:
continue
command = [
"xcodebuild",
"-exportLocalizations",
"-localizationPath", "/tmp/xliff",
"-project", project_path,
"-exportLanguage", locale
]
print "Exporting '%s' to '/tmp/xliff/%s.xliff'" % (locale, locale)
subprocess.call(command)
src_path = "/tmp/xliff/%s.xliff" % locale
dst_path = "%s/%s/firefox-ios.xliff" % (l10n_path, locale)
print "Copying '%s' to '%s'" % (src_path, dst_path)
shutil.copy(src_path, dst_path)