i18nMessageFromPropertyBinding function

I18nMessage? i18nMessageFromPropertyBinding(
  1. ASTWithSource value,
  2. I18nMetadata metadata,
  3. SourceSpan sourceSpan
)

Creates an internationalized message from a bound value with metadata.

Implementation

I18nMessage? i18nMessageFromPropertyBinding(
  ASTWithSource value,
  I18nMetadata metadata,
  SourceSpan sourceSpan,
) {
  final visitor = _I18nPropertyVisitor();
  final context = _I18nPropertyContext();
  try {
    value.ast.visit(visitor, context);
    return context.build(metadata);
  } on _I18nPropertyException catch (e) {
    CompileContext.current.reportAndRecover(BuildError.forSourceSpan(
      sourceSpan,
      e.message,
    ));
    return null;
  }
}