Package com.google.javascript.jscomp
Class JsMessageExtractor
java.lang.Object
com.google.javascript.jscomp.JsMessageExtractor
Extracts messages and message comments from JS code.
Uses a special prefix (e.g. MSG_
) to determine which variables
are messages. Here are the recognized formats:
var MSG_FOO = "foo";
var MSG_FOO_HELP = "this message is used for foo";
var MSG_BAR = function(a, b) {
return a + " bar " + b;
}
var MSG_BAR_HELP = "the bar message";
This class enforces the policy that message variable names must be unique across all JS files.
-
Constructor Summary
ConstructorDescriptionJsMessageExtractor
(JsMessage.IdGenerator idGenerator, JsMessage.Style style) JsMessageExtractor
(JsMessage.IdGenerator idGenerator, JsMessage.Style style, CompilerOptions options) -
Method Summary
Modifier and TypeMethodDescriptionextractMessages
(SourceFile... inputs) Extracts JS messages from JavaScript code.<T extends SourceFile>
Collection<JsMessage>extractMessages
(Iterable<T> inputs) Extracts JS messages from JavaScript code.
-
Constructor Details
-
JsMessageExtractor
-
JsMessageExtractor
public JsMessageExtractor(JsMessage.IdGenerator idGenerator, JsMessage.Style style, CompilerOptions options)
-
-
Method Details
-
extractMessages
Extracts JS messages from JavaScript code.- Throws:
IOException
-
extractMessages
public <T extends SourceFile> Collection<JsMessage> extractMessages(Iterable<T> inputs) throws IOException Extracts JS messages from JavaScript code.- Parameters:
inputs
- the JavaScript source code inputs- Returns:
- the extracted messages collection
- Throws:
IOException
- if there is a problem reading the JS codeRuntimeException
- if there are problems parsing the JS code or the JS messages, or if two messages have the same key
-