Ejemplo n.º 1
0
  private static String[] lookupBundle(
      ResourceBundle rb,
      int len,
      String elementName,
      TextWidth tw,
      OutputContext oc,
      int baseIndex) {

    String[] names = new String[len];
    boolean shortKey = (elementName.length() == 1);

    for (int i = 0; i < len; i++) {
      StringBuilder b = new StringBuilder();
      b.append(elementName);
      b.append('(');

      if (shortKey) {
        char c = tw.name().charAt(0);

        if (oc != OutputContext.STANDALONE) {
          c = Character.toLowerCase(c);
        }

        b.append(c);
      } else {
        b.append(tw.name());

        if (oc == OutputContext.STANDALONE) {
          b.append('|');
          b.append(oc.name());
        }
      }

      b.append(')');
      b.append('_');
      b.append(i + baseIndex);
      String key = b.toString();

      if (rb.containsKey(key)) {
        names[i] = rb.getString(key);
      } else {
        return null;
      }
    }

    return names;
  }
Ejemplo n.º 2
0
  private static String meridiemKey(String meridiem, TextWidth tw, OutputContext oc) {

    char c = tw.name().charAt(0);

    if (oc == OutputContext.FORMAT) {
      c = Character.toLowerCase(c);
    }

    return "P(" + String.valueOf(c) + ")_" + meridiem;
  }
Ejemplo n.º 3
0
    private static String getEnglishPattern(
        String wide, String abbr, String narrow, TextWidth width, PluralCategory category) {

      switch (width) {
        case WIDE:
          return getPluralPattern(wide, category);
        case ABBREVIATED:
        case SHORT:
          return getPluralPattern(abbr, category);
        case NARROW:
          return "{0}" + narrow;
        default:
          throw new UnsupportedOperationException(width.name());
      }
    }