Class JsMessage

java.lang.Object
com.google.javascript.jscomp.JsMessage

public class JsMessage extends 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();
 
  • Method Details

    • getSourceName

      public String getSourceName()
      Gets the message's sourceName.
    • getKey

      public String getKey()
      Gets the message's key, or name (e.g. "MSG_HELLO").
    • isAnonymous

      public boolean isAnonymous()
    • isExternal

      public boolean isExternal()
    • getId

      public String getId()
      Gets the message's id, or name (e.g. "92430284230902938293").
    • getDesc

      public String getDesc()
      Gets the description associated with this message, intended to help translators, or null if this message has no description.
    • 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 List<CharSequence> parts()
      Gets a read-only list of the parts of this message. Each part is either a String or a JsMessage.PlaceholderReference.
    • placeholders

      public Set<String> placeholders()
      Gets a read-only set of the registered placeholders in this message.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isEmpty

      public boolean isEmpty()
      Returns:
      false iff the message is represented by empty string.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object