Skip to content

Commit f68f092

Browse files
committed
Bug 1435181 - Warn about unknown FTL entities in transforms
1 parent 27203c2 commit f68f092

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

fluent/migrate/context.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def getParser(path):
2323
from .cldr import get_plural_categories
2424
from .transforms import Source
2525
from .merge import merge_resource
26+
from .util import get_message
2627
from .errors import (
2728
EmptyLocalizationError, NotSupportedError, UnreadableReferenceError)
2829

@@ -205,11 +206,20 @@ def get_sources(acc, cur):
205206
self.reference_resources[target] = reference_ast
206207

207208
for node in transforms:
209+
ident = node.id.name
208210
# Scan `node` for `Source` nodes and collect the information they
209211
# store into a set of dependencies.
210212
dependencies = fold(get_sources, node, set())
211213
# Set these sources as dependencies for the current transform.
212-
self.dependencies[(target, node.id.name)] = dependencies
214+
self.dependencies[(target, ident)] = dependencies
215+
216+
# The target Fluent message should exist in the reference file. If
217+
# it doesn't, it's probably a typo.
218+
if get_message(reference_ast.body, ident) is None:
219+
logger = logging.getLogger('migrate')
220+
logger.warn(
221+
'Message "{}" was not found in {}'.format(
222+
ident, reference))
213223

214224
# Keep track of localization resource paths which were defined as
215225
# sources in the transforms.

0 commit comments

Comments
 (0)