Skip to content

Commit 7a31836

Browse files
committed
Port changes proposed by Pike in bug 1291693
1 parent bf713da commit 7a31836

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

fluent/migrate/context.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ def __init__(self, lang, reference_dir, localization_dir):
5151

5252
# An iterable of plural category names relevant to the context's
5353
# language. E.g. ('one', 'other') for English.
54-
self.plural_categories = get_plural_categories(lang)
54+
try:
55+
self.plural_categories = get_plural_categories(lang)
56+
except RuntimeError as e:
57+
print(e.message)
58+
self.plural_categories = 'en'
5559

5660
# Paths to directories with input data, relative to CWD.
5761
self.reference_dir = reference_dir

tools/migrate/blame.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import hglib
55
from hglib.util import b, cmdbuilder
6-
from compare_locales.parser import getParser
6+
from compare_locales.parser import getParser, Junk
77

88

99
class Blame(object):
@@ -33,7 +33,11 @@ def handleFile(self, leaf):
3333
entities, emap = parser.parse()
3434
self.blame[leaf] = {}
3535
for e in entities:
36-
blines = blames[(e.value_position()[0] - 1):e.value_position(-1)[0]]
36+
if isinstance(e, Junk):
37+
continue
38+
blines = blames[
39+
(e.value_position()[0] - 1):e.value_position(-1)[0]
40+
]
3741
blines.sort(key=lambda blame: -blame['date'][0]) # ignore timezone
3842
blame = blines[0]
3943
user = blame['user']

tools/migrate/migrate-l10n.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def main(lang, reference_dir, localization_dir, blame, migrations, dry_run):
4545
fullpath = os.path.join(localization_dir, path)
4646
print(' Writing to {}'.format(fullpath))
4747
if not dry_run:
48+
fulldir = os.path.dirname(fullpath)
49+
if not os.path.isdir(fulldir):
50+
os.makedirs(fulldir)
4851
with open(fullpath, 'w') as f:
4952
f.write(content.encode('utf8'))
5053
f.close()

0 commit comments

Comments
 (0)