src/main/java/com/teamunify/i18n/I.java
public static String localizedStringsAsList(String preTranslatedWords[], boolean inclusive, EscapeFunction f) {
    String comma = I.trc("The separator for lists in a sentence (e.g. a, b, and c)", ",", f);
    String justTwo =
      inclusive ? I.trc("a list in a sentence with more exactly two things", "{0} and {1}", f)
                : I.trc("a list of options in a sentence with exactly two things", "{0} or {1}", f);
    String compoundList =
      inclusive ? I.trc("ending of list in a sentence with three or more things", "{0}, and {1}", f)
                : I.trc("ending of list of options in a sentence with three or more things", "{0}, or {1}", f);

    if (preTranslatedWords == null || preTranslatedWords.length == 0)
      return "";
    if (preTranslatedWords.length == 1)
      return preTranslatedWords[0];
    if (preTranslatedWords.length == 2)
      return I.trf(f, justTwo, preTranslatedWords[0], preTranslatedWords[1]);

    StringBuilder mainList = new StringBuilder();
    int i = 0;
    for (i = 0; i < preTranslatedWords.length - 1; i++) {
      mainList.append(preTranslatedWords[i]);
      if (i < preTranslatedWords.length - 2) {
        mainList.append(comma);
        mainList.append(' ');
      }
    }

    return I.trf(f, compoundList, mainList.toString(), preTranslatedWords[i]);
  }
/**
   * Languages deal with compond lists in a sentence differently. For example, in English the proper format is:
   * <p/>
   * <pre>
   *  two items: "a and b"
   *  three or more items: "a, b, c, and d"
   * </pre>
   * <p>
   * However, other languages may not use comma, and may or may not have words that separate the last item from the rest
   * of the list.
   * <p>
   * This function centralizes the handling of proper sentence structure for lists like this. Most list classes (e.g.
   * ArrayList, Vector, TreeSet) have a toArray() method, so this expects an array of strings that are your list.
   * <p/>
   * <p>
   * <b>NOTE: the strings you pass must have been previous translated!</b>. If you have a list of literals, use a
   * pattern like:
   * </p>
   * <p/>
   * <pre>
   * I.localizedStringsAsList(I.tr(&quot;A&quot;), I.tr(&quot;B&quot;), I.tr(&quot;C&quot;));
   * </pre>
   * <p/>
   * Remember, <b>it is impossible for the translation system to translate strings from variables.</b>
   *
   * @param preTranslatedWords Words you've already run through tr (as literals). May be null, empty, or singular.
   * @param inclusive          Pass true to use "And", false to use "Or". E.g. A, B, and C vs. A, B, or C.
   * @return A stringified list acceptable for use in the middle of a sentence. e.g. String[] { I.tr("A"), I.tr("B"),
   * I.tr("B") } -&gt; "A, B, and C". If you pass a null list or empty list, "" is returned. If you pass a list
   * with a single item, just that item is returned. Never returns null.
   */
Languages deal with compond lists in a sentence differently. For example, in English the proper format is:


two items: "a and b"
three or more items: "a, b, c, and d"


However, other languages may not use comma, and may or may not have words that separate the last item from the rest
of the list.

This function centralizes the handling of proper sentence structure for lists like this. Most list classes  have a toArray() method, so this expects an array of strings that are your list.


NOTE: the strings you pass must have been previous translated!.

@param preTranslatedWords Words you've already run through tr (as literals). May be null, empty, or singular.
@param inclusive          Pass true to use "And", false to use "Or".
Languages deal with compond lists in a sentence differently . For example in English the proper format is : two items : " a and b " three or more items : " a b c and d " However other languages may not use comma and may or may not have words that separate the last item from the rest of the list . This function centralizes the handling of proper sentence structure for lists like this . Most list classes have a toArray () method so this expects an array of strings that are your list . NOTE : the strings you pass must have been previous translated! . @param preTranslatedWords Words you ' ve already run through tr ( as literals ) . May be null empty or singular . @param inclusive Pass true to use " And " false to use " Or " .
public static String localizedStringsAsList(String preTranslatedWords[], boolean inclusive, EscapeFunction f) {
    String comma = I.trc("The separator for lists in a sentence (e.g. a, b, and c)", ",", f);
    String justTwo =
      inclusive ? I.trc("a list in a sentence with more exactly two things", "{0} and {1}", f)
                : I.trc("a list of options in a sentence with exactly two things", "{0} or {1}", f);
    String compoundList =
      inclusive ? I.trc("ending of list in a sentence with three or more things", "{0}, and {1}", f)
                : I.trc("ending of list of options in a sentence with three or more things", "{0}, or {1}", f);
    if (preTranslatedWords == null || preTranslatedWords.length == 0)
      return "";
    if (preTranslatedWords.length == 1)
      return preTranslatedWords[0];
    if (preTranslatedWords.length == 2)
      return I.trf(f, justTwo, preTranslatedWords[0], preTranslatedWords[1]);
    StringBuilder mainList = new StringBuilder();
    int i = 0;
    for (i = 0; i < preTranslatedWords.length - 1; i++) {
      mainList.append(preTranslatedWords[i]);
      if (i < preTranslatedWords.length - 2) {
        mainList.append(comma);
        mainList.append(' ');
      }
    }
    return I.trf(f, compoundList, mainList.toString(), preTranslatedWords[i]);
  }
public static String localizedStringsAsList ( String preTranslatedWords [ ] , boolean inclusive , EscapeFunction f ) { String comma = I . trc ( "The separator for lists in a sentence (e.g. a, b, and c)" , "," , f ) ; String justTwo = inclusive ? I . trc ( "a list in a sentence with more exactly two things" , "{0} and {1}" , f ) : I . trc ( "a list of options in a sentence with exactly two things" , "{0} or {1}" , f ) ; String compoundList = inclusive ? I . trc ( "ending of list in a sentence with three or more things" , "{0}, and {1}" , f ) : I . trc ( "ending of list of options in a sentence with three or more things" , "{0}, or {1}" , f ) ; if ( preTranslatedWords == null || preTranslatedWords . length == 0 ) return "" ; if ( preTranslatedWords . length == 1 ) return preTranslatedWords [ 0 ] ; if ( preTranslatedWords . length == 2 ) return I . trf ( f , justTwo , preTranslatedWords [ 0 ] , preTranslatedWords [ 1 ] ) ; StringBuilder mainList = new StringBuilder ( ) ; int i = 0 ; for ( i = 0 ; i < preTranslatedWords . length - 1 ; i ++ ) { mainList . append ( preTranslatedWords [ i ] ) ; if ( i < preTranslatedWords . length - 2 ) { mainList . append ( comma ) ; mainList . append ( ' ' ) ; } } return I . trf ( f , compoundList , mainList . toString ( ) , preTranslatedWords [ i ] ) ; }
Languages deal with compond lists in a sentence differently.
Languages deal with compond lists in a sentence differently .