com.google.javascript.jscomp
Class XtbMessageBundle

java.lang.Object
  extended by com.google.javascript.jscomp.XtbMessageBundle
All Implemented Interfaces:
MessageBundle

public class XtbMessageBundle
extends Object
implements MessageBundle

A MessageBundle that parses messages from an XML Translation Bundle (XTB) file.


Constructor Summary
XtbMessageBundle(InputStream xtb, String projectId)
          Creates an instance and initializes it with the messages in an XTB file.
XtbMessageBundle(InputStream xtb, String projectId, boolean unused)
           
 
Method Summary
 Iterable<JsMessage> getAllMessages()
          Returns an iterable over the keys that this object has replacements for.
 JsMessage getMessage(String id)
          Gets a message replacement.
 JsMessage.IdGenerator idGenerator()
          Gets the message ID generator to use to compute message IDs for this type of bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XtbMessageBundle

public XtbMessageBundle(InputStream xtb,
                        @Nullable
                        String projectId,
                        boolean unused)

XtbMessageBundle

public XtbMessageBundle(InputStream xtb,
                        @Nullable
                        String projectId)
Creates an instance and initializes it with the messages in an XTB file.

Parameters:
xtb - the XTB file as a byte stream
projectId - the translation console project id (i.e. name)
Method Detail

getMessage

public JsMessage getMessage(String id)
Description copied from interface: MessageBundle
Gets a message replacement.

Specified by:
getMessage in interface MessageBundle
Parameters:
id - the id of the message being replaced; the key is message ID generated by JsMessage.IdGenerator
Returns:
the message replacement, which may be null.

idGenerator

public JsMessage.IdGenerator idGenerator()
Description copied from interface: MessageBundle
Gets the message ID generator to use to compute message IDs for this type of bundle.

Specified by:
idGenerator in interface MessageBundle
Returns:
idGenerator instance or null if we do not want to use any custom id generation. In case if idGenerator is null caller should decide how to create id by itself. In the most cases using the message key is enough.

getAllMessages

public Iterable<JsMessage> getAllMessages()
Description copied from interface: MessageBundle
Returns an iterable over the keys that this object has replacements for.

Specified by:
getAllMessages in interface MessageBundle
Returns:
all messages from this bundle.