Class XtbMessageBundle

  • All Implemented Interfaces:
    MessageBundle

    @GwtIncompatible("Currently not used in GWT version")
    public final class XtbMessageBundle
    extends java.lang.Object
    implements MessageBundle
    A MessageBundle that parses messages from an XML Translation Bundle (XTB) file. TODO(moz): Make this GWT compatible.
    • Constructor Summary

      Constructors 
      Constructor Description
      XtbMessageBundle​(java.io.InputStream xtb, java.lang.String projectId)
      Creates an instance and initializes it with the messages in an XTB file.
      XtbMessageBundle​(java.io.InputStream xtb, java.lang.String projectId, boolean unused)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Iterable<JsMessage> getAllMessages()
      Returns an iterable over the keys that this object has replacements for.
      JsMessage getMessage​(java.lang.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​(java.io.InputStream xtb,
                                @Nullable
                                java.lang.String projectId,
                                boolean unused)
      • XtbMessageBundle

        public XtbMessageBundle​(java.io.InputStream xtb,
                                @Nullable
                                java.lang.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​(java.lang.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 java.lang.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.