Package com.google.javascript.jscomp
Class JsMessage
- java.lang.Object
-
- com.google.javascript.jscomp.JsMessage
-
public final 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.PlaceholderReference
A reference to a placeholder in a translatable message.static class
JsMessage.Style
Message style that could be used for JS code parsing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.String
getAlternateId()
Gets the message's alternate ID (e.g.java.lang.String
getDesc()
Gets the description associated with this message, intended to help translators, or null if this message has no description.java.lang.String
getId()
Gets the message's id, or name (e.g.java.lang.String
getKey()
Gets the message's key, or name (e.g.java.lang.String
getMeaning()
Gets the meaning annotated to the message, intended to force different translations.java.lang.String
getSourceName()
Gets the message's sourceName.int
hashCode()
boolean
isAnonymous()
boolean
isEmpty()
boolean
isExternal()
boolean
isHidden()
Gets whether this message should be hidden from volunteer translators (to reduce the chances of a new feature leak).java.util.List<java.lang.CharSequence>
parts()
Gets a read-only list of the parts of this message.java.util.Set<java.lang.String>
placeholders()
Gets a read-only set of the registered placeholders in this message.java.lang.String
toString()
-
-
-
Method Detail
-
getSourceName
public java.lang.String getSourceName()
Gets the message's sourceName.
-
getKey
public java.lang.String getKey()
Gets the message's key, or name (e.g."MSG_HELLO"
).
-
isAnonymous
public boolean isAnonymous()
-
isExternal
public boolean isExternal()
-
getId
public java.lang.String getId()
Gets the message's id, or name (e.g."92430284230902938293"
).
-
getAlternateId
@Nullable public 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
public java.lang.String getDesc()
Gets the description associated with this message, intended to help translators, or null if this message has no description.
-
getMeaning
public java.lang.String getMeaning()
Gets the meaning annotated to the message, intended to force different translations.
-
isHidden
public boolean isHidden()
Gets whether this message should be hidden from volunteer translators (to reduce the chances of a new feature leak).
-
parts
public java.util.List<java.lang.CharSequence> parts()
Gets a read-only list of the parts of this message. Each part is either aString
or aJsMessage.PlaceholderReference
.
-
placeholders
public java.util.Set<java.lang.String> placeholders()
Gets a read-only set of the registered placeholders in this message.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isEmpty
public boolean isEmpty()
- Returns:
- false iff the message is represented by empty string.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-