MessageUtils { public static String serializeMsgstr(Message message) { if (message.isPlural()) { StringBuilder sb = new StringBuilder(); List<String> plurals = message.getMsgstrPlural(); for (Iterator<String> it=plurals.iterator(); it.hasNext(); ) { String plural = it.next(); sb.append(plural); if (it.hasNext()) { sb.append("\u0000"); } } return sb.toString(); } else { String msgstr = message.getMsgstr(); return msgstr == null ? "" : msgstr; } }  static String getPluralForms(Message header); static String serializeMsgid(String msgctx, String msgid); static String serializeMsgid(Message msg); static String serializeMsgstr(Message message); static byte[] serializeMsgstrUTF8(Message message); static byte[] serializeMsgidUTF8(Message message);  }
@Test public void testString() { Message msg = new Message(); msg.setMsgid("id"); msg.setMsgstr("str"); Assert.assertEquals("str", MessageUtils.serializeMsgstr(msg)); }
@Test public void testStringPlural() { Message msg = new Message(); msg.setMsgid("id"); msg.setMsgidPlural("ids"); msg.addMsgstrPlural("id", 0); msg.addMsgstrPlural("ids", 1); Assert.assertEquals("id\u0000ids", MessageUtils.serializeMsgstr(msg)); }