Package com.google.javascript.jscomp
Class JsMessage
- java.lang.Object
-
- com.google.javascript.jscomp.JsMessage
-
public abstract class JsMessage extends java.lang.Object
A representation of a translatable message in JavaScript source code.Instances are created using a
JsMessage.Builder
, like this:JsMessage m = new JsMessage.Builder(key) .appendPart("Hi ") .appendPlaceholderReference("firstName") .appendPart("!") .setDesc("A welcome message") .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsMessage.Builder
Contains functionality for creating JS messages.static interface
JsMessage.IdGenerator
ID generatorstatic class
JsMessage.PlaceholderFormatException
Thrown when parsing a message string into parts fails because of a misformatted place holder.static class
JsMessage.PlaceholderReference
A reference to a placeholder in a translatable message.static class
JsMessage.Style
Message style that could be used for JS code parsing.
-
Constructor Summary
Constructors Constructor Description JsMessage()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.lang.String
getAlternateId()
Gets the message's alternate ID (e.g.abstract java.lang.String
getDesc()
Gets the description associated with this message, intended to help translators, or null if this message has no description.abstract java.lang.String
getId()
Gets the message's id, or name (e.g.abstract java.lang.String
getKey()
Gets the message's key, or name (e.g.abstract java.lang.String
getMeaning()
Gets the meaning annotated to the message, intended to force different translations.abstract com.google.common.collect.ImmutableList<java.lang.CharSequence>
getParts()
Gets a read-only list of the parts of this message.abstract java.lang.String
getSourceName()
Gets the message's sourceName.abstract boolean
isAnonymous()
boolean
isEmpty()
abstract boolean
isExternal()
abstract boolean
isHidden()
Gets whether this message should be hidden from volunteer translators (to reduce the chances of a new feature leak).com.google.common.collect.ImmutableList<java.lang.CharSequence>
parts()
Deprecated.usegetParts()
} insteadabstract com.google.common.collect.ImmutableSet<java.lang.String>
placeholders()
Gets a set of the registered placeholders in this message.java.lang.String
toString()
Returns a String containing the original message text.
-
-
-
Method Detail
-
getSourceName
@Nullable public abstract java.lang.String getSourceName()
Gets the message's sourceName.
-
getKey
public abstract java.lang.String getKey()
Gets the message's key, or name (e.g."MSG_HELLO"
).
-
isAnonymous
public abstract boolean isAnonymous()
-
isExternal
public abstract boolean isExternal()
-
getId
public abstract java.lang.String getId()
Gets the message's id, or name (e.g."92430284230902938293"
).
-
getParts
public abstract com.google.common.collect.ImmutableList<java.lang.CharSequence> getParts()
Gets a read-only list of the parts of this message. Each part is either aString
or aJsMessage.PlaceholderReference
.
-
getAlternateId
@Nullable public abstract java.lang.String getAlternateId()
Gets the message's alternate ID (e.g."92430284230902938293"
), if available. This will be used if a translation for `id` is not available.
-
getDesc
@Nullable public abstract java.lang.String getDesc()
Gets the description associated with this message, intended to help translators, or null if this message has no description.
-
getMeaning
@Nullable public abstract java.lang.String getMeaning()
Gets the meaning annotated to the message, intended to force different translations.
-
isHidden
public abstract boolean isHidden()
Gets whether this message should be hidden from volunteer translators (to reduce the chances of a new feature leak).
-
parts
@Deprecated public final com.google.common.collect.ImmutableList<java.lang.CharSequence> parts()
Deprecated.usegetParts()
} insteadGets a list of the parts of this message. Each part is either aString
or aJsMessage.PlaceholderReference
.
-
placeholders
public abstract com.google.common.collect.ImmutableSet<java.lang.String> placeholders()
Gets a set of the registered placeholders in this message.
-
toString
public final java.lang.String toString()
Returns a String containing the original message text.- Overrides:
toString
in classjava.lang.Object
-
isEmpty
public final boolean isEmpty()
- Returns:
- false iff the message is represented by empty string.
-
-