/** * Render a {@code {plural}} part of a message. Most of the complexity is handled by {@link * SoyMsgPluralPart#lookupCase} all this needs to do is apply the placeholders to all the * children. */ private static void renderPlural( @Nullable ULocale locale, SoyMsgPluralPart plural, Map<String, Object> placeholders, Appendable out) throws IOException { long pluralValue = getPlural(placeholders, plural.getPluralVarName()); for (SoyMsgPart casePart : plural.lookupCase(pluralValue, locale)) { if (casePart instanceof SoyMsgPlaceholderPart) { writePlaceholder((SoyMsgPlaceholderPart) casePart, placeholders, out); } else if (casePart instanceof SoyMsgRawTextPart) { writeRawText((SoyMsgRawTextPart) casePart, out); } else if (casePart instanceof SoyMsgPluralRemainderPart) { out.append(String.valueOf(pluralValue - plural.getOffset())); } else { // Plural parts will not have nested plural/select parts. So, this is an error. throw new AssertionError("unexpected part: " + casePart); } } }
SoyMsgPluralPart pluralPart = (SoyMsgPluralPart) first; long pluralValue = getPlural(pluralPart.getPluralVarName()); parts = pluralPart.lookupCase(pluralValue, locale);
List<SoyMsgPart> caseParts = pluralPart.lookupCase((int) correctPluralValue, locale);
List<SoyMsgPart> caseParts = pluralPart.lookupCase((int) correctPluralValue, locale);