示例#1
0
  /**
   * Retrieves the plural translation for msgid1.
   * 
   * @param env
   * @param domain
   * @param category
   * @param msgid1
   * @param msgid2
   *
   * @return translation found, else msgid1 if n == 1, else msgid2
   */
  private StringValue translate(Env env,
                                GettextDomain domain,
                                CharSequence category,
                                StringValue msgid1,
                                StringValue msgid2,
                                int quantity,
                                Value []args)
  {
    Locale locale = env.getLocaleInfo().getMessages().getLocale();

    GettextResource resource = getResource(env,
                                           domain.getPath(),
                                           locale,
                                           category,
                                           domain.getName());

    StringValue unicodeTranslation
      = resource.getTranslation(msgid1, quantity);

    if (unicodeTranslation == null)
      unicodeTranslation = errorReturn(msgid1, msgid2, quantity);

    StringValue translation = msgid1.create(env, unicodeTranslation, domain.getCharset());
    
    return format(env, translation, args);
  }