Package com.google.template.soy.msgs.restricted

Examples of com.google.template.soy.msgs.restricted.SoyMsg


    boolean doAddEnvFrame = node.needsEnvFrameDuringInterp() != Boolean.FALSE /*true or unknown*/;
    if (doAddEnvFrame) {
      env.push(Maps.<String, SoyData>newHashMap());
    }

    SoyMsg soyMsg;
    if (msgBundle != null) {
      long msgId = MsgUtils.computeMsgIdForDualFormat(node);
      soyMsg = msgBundle.getMsg(msgId);
    } else {
      soyMsg = null;
    }

    if (soyMsg != null) {
      // Case 1: Localized message is provided by the msgBundle.

      List<SoyMsgPart> msgParts = soyMsg.getParts();

      if (msgParts.size() > 0) {
        SoyMsgPart firstPart = msgParts.get(0);

        if (firstPart instanceof SoyMsgPluralPart) {
          new PlrselMsgPartsVisitor(node, new ULocale(soyMsg.getLocaleString()))
              .visitPart((SoyMsgPluralPart) firstPart);

        } else if (firstPart instanceof SoyMsgSelectPart) {
          new PlrselMsgPartsVisitor(node, new ULocale(soyMsg.getLocaleString()))
              .visitPart((SoyMsgSelectPart) firstPart);

        } else {
          for (SoyMsgPart msgPart : msgParts) {

View Full Code Here


          currMsgParts.add(new SoyMsgRawTextPart(currRawTextPart));
          currRawTextPart = null;
        }
        isInMsg = false;
        if (currMsgParts.size() > 0) {
          msgs.add(new SoyMsg(
              currMsgId, targetLocaleString, null, null, false, null, null, currMsgParts));
        }
      }
    }
View Full Code Here

    // Process the message to build the list of replacement nodes.
    currMsgReplacementNodes = Lists.newArrayList();

    long msgId = MsgUtils.computeMsgIdForDualFormat(node);
    SoyMsg soyMsg = (msgBundle == null) ? null : msgBundle.getMsg(msgId);

    if (soyMsg != null) {
      // Case 1: Localized message is provided by the msgBundle.
      for (SoyMsgPart msgPart : soyMsg.getParts()) {

        if (msgPart instanceof SoyMsgRawTextPart) {
          // Append a new RawTextNode to the currMsgReplacementNodes list.
          String rawText = ((SoyMsgRawTextPart) msgPart).getRawText();
          currMsgReplacementNodes.add(new RawTextNode(nodeIdGen.genId(), rawText));
View Full Code Here


  @Override protected void visitMsgNode(MsgNode node) {

    MsgPartsAndIds msgPartsAndIds = MsgUtils.buildMsgPartsAndComputeMsgIdForDualFormat(node);
    msgs.add(new SoyMsg(
        msgPartsAndIds.id, -1L, null, node.getMeaning(), node.getDesc(), node.isHidden(),
        node.getContentType(), currentSource, node.isPlrselMsg(), msgPartsAndIds.parts));
  }
View Full Code Here

    for (SoyMsg msg : msgBundle) {
      msgs.add(msg);
    }
    assertEquals(5, msgs.size());

    SoyMsg moscowMsg = msgs.get(0);
    assertEquals(626010707674174792L, moscowMsg.getId());
    List<SoyMsgPart> moscowMsgParts = moscowMsg.getParts();
    assertEquals(1, moscowMsgParts.size());
    assertEquals("Zmoscow", ((SoyMsgRawTextPart) moscowMsgParts.get(0)).getRawText());

    assertEquals(948230478248061386L, msgs.get(1).getId());

    SoyMsg mooseMsg = msgs.get(2);
    assertEquals(2764913337766789440L, mooseMsg.getId());
    List<SoyMsgPart> mooseMsgParts = mooseMsg.getParts();
    assertEquals(7, mooseMsgParts.size());
    assertEquals("Zmoose ", ((SoyMsgRawTextPart) mooseMsgParts.get(0)).getRawText());
    assertEquals("START_ITALIC",
                 ((SoyMsgPlaceholderPart) mooseMsgParts.get(1)).getPlaceholderName());
    assertEquals("zalso", ((SoyMsgRawTextPart) mooseMsgParts.get(2)).getRawText());
    assertEquals("END_ITALIC",
                 ((SoyMsgPlaceholderPart) mooseMsgParts.get(3)).getPlaceholderName());
    assertEquals(" zsays ", ((SoyMsgRawTextPart) mooseMsgParts.get(4)).getRawText());
    assertEquals("XXX", ((SoyMsgPlaceholderPart) mooseMsgParts.get(5)).getPlaceholderName());
    assertEquals(".", ((SoyMsgRawTextPart) mooseMsgParts.get(6)).getRawText());

    SoyMsg cowMsg = msgs.get(3);
    assertEquals(6632711700686641662L, cowMsg.getId());
    List<SoyMsgPart> cowMsgParts = cowMsg.getParts();
    assertEquals(3, cowMsgParts.size());
    assertEquals("Zcow zsays ", ((SoyMsgRawTextPart) cowMsgParts.get(0)).getRawText());
    assertEquals("MOO", ((SoyMsgPlaceholderPart) cowMsgParts.get(1)).getPlaceholderName());
    assertEquals(".", ((SoyMsgRawTextPart) cowMsgParts.get(2)).getRawText());
View Full Code Here

TOP

Related Classes of com.google.template.soy.msgs.restricted.SoyMsg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.