Skip to content

Commit

Permalink
Bug 1435181 - Warn about unknown FTL entities in transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Feb 2, 2018
1 parent 27203c2 commit f68f092
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fluent/migrate/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def getParser(path):
from .cldr import get_plural_categories
from .transforms import Source
from .merge import merge_resource
from .util import get_message
from .errors import (
EmptyLocalizationError, NotSupportedError, UnreadableReferenceError)

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

for node in transforms:
ident = node.id.name
# Scan `node` for `Source` nodes and collect the information they
# store into a set of dependencies.
dependencies = fold(get_sources, node, set())
# Set these sources as dependencies for the current transform.
self.dependencies[(target, node.id.name)] = dependencies
self.dependencies[(target, ident)] = dependencies

# The target Fluent message should exist in the reference file. If
# it doesn't, it's probably a typo.
if get_message(reference_ast.body, ident) is None:
logger = logging.getLogger('migrate')
logger.warn(
'Message "{}" was not found in {}'.format(
ident, reference))

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

0 comments on commit f68f092

Please sign in to comment.