예제 #1
1
 public void enforceLocale(Activity activity) {
   Configuration config = activity.getBaseContext().getResources().getConfiguration();
   if (!mLocale.equals(config.locale)) {
     config.locale = mLocale;
     activity.getBaseContext().getResources().updateConfiguration(config, null);
   }
 }
예제 #2
0
 @Override
 public String getDisplayName(Locale locale) {
   if (locale != null && locale.equals(Locale.KOREAN)) return "로그 선택자";
   if (locale != null && locale.equals(Locale.JAPANESE)) return "ログセレクター";
   if (locale != null && locale.equals(Locale.CHINESE)) return "数据筛选器";
   return "Log Selector";
 }
예제 #3
0
  protected void drawMonthDayLabels(Canvas canvas) {
    int y = getMonthHeaderSize() - (MONTH_DAY_LABEL_TEXT_SIZE / 2);
    int dayWidthHalf = (mWidth - mEdgePadding * 2) / (mNumDays * 2);

    for (int i = 0; i < mNumDays; i++) {
      int x = (2 * i + 1) * dayWidthHalf + mEdgePadding;

      int calendarDay = (i + mWeekStart) % mNumDays;
      mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay);
      Locale locale = Locale.getDefault();
      String localWeekDisplayName =
          mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale);
      String weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1);

      if (locale.equals(Locale.CHINA)
          || locale.equals(Locale.CHINESE)
          || locale.equals(Locale.SIMPLIFIED_CHINESE)
          || locale.equals(Locale.TRADITIONAL_CHINESE)) {
        int len = localWeekDisplayName.length();
        weekString = localWeekDisplayName.substring(len - 1, len);
      }

      if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) {
        if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
          int len = localWeekDisplayName.length();
          weekString = localWeekDisplayName.substring(len - 2, len - 1);
        } else {
          // I know this is duplication, but it makes the code easier to grok by
          // having all hebrew code in the same block
          weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1);
        }
      }
      canvas.drawText(weekString, x, y, mMonthDayLabelPaint);
    }
  }
예제 #4
0
 @Override
 public String getDisplayName(Locale locale) {
   if (locale != null && locale.equals(Locale.KOREAN)) return "로테이션 로그 파일";
   if (locale != null && locale.equals(Locale.JAPANESE)) return "ローテーションログファイル";
   if (locale != null && locale.equals(Locale.CHINESE)) return "回滚日志文件";
   return "Rotation Log File";
 }
예제 #5
0
 @Override
 public String getDescription(Locale locale) {
   if (locale != null && locale.equals(Locale.KOREAN)) return "다른 로거로부터 패턴 매칭되는 특정 로그들만 수집합니다.";
   if (locale != null && locale.equals(Locale.JAPANESE)) return "他のロガーからパターンマッチングされる特定ログだけ収集します。";
   if (locale != null && locale.equals(Locale.CHINESE)) return "从其他数据采集器提取符合指定特征的数据。";
   return "Select logs from logger using text matching";
 }
예제 #6
0
 @Override
 public String getDisplayName(Locale locale) {
   if (locale != null && locale.equals(Locale.KOREAN)) return "정규표현식 로그 선택자";
   if (locale != null && locale.equals(Locale.JAPANESE)) return "正規表現ログセレクター";
   if (locale != null && locale.equals(Locale.CHINESE)) return "正则表达式筛选器";
   return "Regex Selector";
 }
예제 #7
0
 /** @return 01092010 */
 public static String getDateNumeric() {
   String year = getYear();
   String month = getMonth();
   String day = getDayOfMonth();
   String dn = year + month + day;
   if (mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("item.date.locale")
       == null)
     mpv5.db.objects.User.getCurrentUser()
         .getProperties()
         .changeProperty("item.date.locale", Locale.getDefault().toString());
   try {
     Locale l =
         TypeConversion.stringToLocale(
             mpv5.db.objects.User.getCurrentUser()
                 .getProperties()
                 .getProperty("item.date.locale"));
     if (l.equals(Locale.GERMAN) || l.equals(Locale.GERMANY)) {
       dn = day + month + year;
     }
   } catch (Exception e) {
     Log.Debug(e);
   } finally {
     return dn;
   }
 }
예제 #8
0
 @Override
 public String getDescription(Locale locale) {
   if (locale != null && locale.equals(Locale.KOREAN))
     return "다른 로거로부터 정규표현식 패턴이 매칭되는 특정 로그들만 수집합니다.";
   if (locale != null && locale.equals(Locale.JAPANESE)) return "他のロガーから正規表現がマッチングされるログだけ収集します。";
   if (locale != null && locale.equals(Locale.CHINESE)) return "从源数据采集器采集的数据中提取符合正则表达式特征的数据。";
   return "Select logs from logger using regular expression pattern matching";
 }
예제 #9
0
 public boolean equals(Object o) {
   if (!(o instanceof BundleKey)) return false;
   BundleKey key = (BundleKey) o;
   return hashcode == key.hashcode
       && defaultLocale.equals(key.defaultLocale)
       && baseName.equals(key.baseName)
       && locale.equals(key.locale)
       && classLoader.equals(key.classLoader);
 }
예제 #10
0
 @Override
 public String getDescription(Locale locale) {
   if (locale != null && locale.equals(Locale.KOREAN))
     return "일정 주기마다 다른 경로에 백업 후 삭제하고 다시 쓰는 로그 파일을 수집합니다.";
   if (locale != null && locale.equals(Locale.JAPANESE))
     return "一定周期で他の経路にバックアップしたあと削除し、書き換えるログファイルを収集します。";
   if (locale != null && locale.equals(Locale.CHINESE)) return "采集定期备份到其他路径之后删除并重新写的日志文件。";
   return "Collect rotation text log files";
 }
 @Test
 public void defaultLocale() {
   Locale originalDefaultLocale = Locale.getDefault();
   try {
     Locale newDefaultLocale =
         originalDefaultLocale.equals(Locale.GERMANY) ? Locale.FRANCE : Locale.GERMANY;
     Locale.setDefault(newDefaultLocale);
     // Create the request after changing the default locale.
     MockHttpServletRequest request = new MockHttpServletRequest();
     assertFalse(newDefaultLocale.equals(request.getLocale()));
     assertEquals(Locale.ENGLISH, request.getLocale());
   } finally {
     Locale.setDefault(originalDefaultLocale);
   }
 }
  private synchronized void updateText(long now) {
    long seconds = now - mBase;
    seconds /= 1000;
    String text = DateUtils.formatElapsedTime(mRecycle, seconds);

    if (mFormat != null) {
      Locale loc = Locale.getDefault();
      if (mFormatter == null || !loc.equals(mFormatterLocale)) {
        mFormatterLocale = loc;
        mFormatter = new Formatter(mFormatBuilder, loc);
      }
      mFormatBuilder.setLength(0);
      mFormatterArgs[0] = text;
      try {
        mFormatter.format(mFormat, mFormatterArgs);
        text = mFormatBuilder.toString();
      } catch (IllegalFormatException ex) {
        if (!mLogged) {
          Log.w(TAG, "Illegal format string: " + mFormat);
          mLogged = true;
        }
      }
    }
    setText(text);
  }
 protected void service(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   final Locale locale = localeResolver.resolveLocale(request);
   LocaleContextHolder.setLocale(locale);
   ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
   RequestContextHolder.setRequestAttributes(requestAttributes);
   try {
     super.service(
         new HttpServletRequestWrapper(request) {
           @Override
           public Locale getLocale() {
             return locale;
           }
         },
         response);
   } finally {
     if (!locale.equals(LocaleContextHolder.getLocale())) {
       if (logger.isDebugEnabled()) {
         logger.debug("locale changed, updating locale resolver");
       }
       localeResolver.setLocale(request, response, LocaleContextHolder.getLocale());
     }
     LocaleContextHolder.resetLocaleContext();
     RequestContextHolder.resetRequestAttributes();
   }
 }
 /**
  * Returns a new formatter with a different locale that will be used for printing and parsing.
  *
  * <p>A DateTimeFormatter is immutable, so a new instance is returned, and the original is
  * unaltered and still usable.
  *
  * @param locale the locale to use; if null, formatter uses default locale at invocation time
  * @return the new formatter
  */
 public DateTimeFormatter withLocale(Locale locale) {
   if (locale == getLocale() || (locale != null && locale.equals(getLocale()))) {
     return this;
   }
   return new DateTimeFormatter(
       iPrinter, iParser, locale, iOffsetParsed, iChrono, iZone, iPivotYear, iDefaultYear);
 }
예제 #15
0
 public int a(Locale paramLocale1, Locale paramLocale2) {
   if (paramLocale1.equals(paramLocale2)) {
     return 0;
   }
   return String.valueOf(paramLocale1.getLanguage())
       .compareToIgnoreCase(String.valueOf(paramLocale2.getLanguage()));
 }
예제 #16
0
  /**
   * Returns true if user preference with the given user handle is set to 24-hour format.
   *
   * @param setting value of the TIME_12_24 system setting, which may be null
   * @param locale current default locale for this device
   * @param userHandle the user handle of the user to query.
   * @return true if 24 hour time format is selected, false otherwise.
   * @hide
   */
  public static boolean is24HourFormat(String setting, Locale locale) {
    if (setting == null) {
      synchronized (sLocaleLock) {
        if (sIs24HourLocale != null && sIs24HourLocale.equals(locale)) {
          return sIs24Hour;
        }
      }

      java.text.DateFormat natural =
          java.text.DateFormat.getTimeInstance(java.text.DateFormat.LONG, locale);

      if (natural instanceof SimpleDateFormat) {
        SimpleDateFormat sdf = (SimpleDateFormat) natural;
        String pattern = sdf.toPattern();

        if (pattern.indexOf('H') >= 0) {
          setting = "24";
        } else {
          setting = "12";
        }
      } else {
        setting = "12";
      }

      synchronized (sLocaleLock) {
        sIs24HourLocale = locale;
        sIs24Hour = setting.equals("24");
      }

      return sIs24Hour;
    }

    return setting.equals("24");
  }
  private void addWikiTranslation(String key, String message, Locale locale) throws XWikiException {
    XWikiDocument document =
        this.oldcore
            .getMockXWiki()
            .getDocument(this.defaultWikiTranslationReference, this.oldcore.getXWikiContext());

    if (!locale.equals(Locale.ROOT)) {
      XWikiDocument translatedDocument =
          document.getTranslatedDocument(locale, this.oldcore.getXWikiContext());
      if (translatedDocument == document) {
        translatedDocument = new XWikiDocument(document.getDocumentReference(), locale);
        translatedDocument.setDefaultLocale(document.getDefaultLocale());
      }
      document = translatedDocument;
    }

    document.setSyntax(Syntax.PLAIN_1_0);

    StringBuilder builder = new StringBuilder(document.getContent());

    builder.append('\n');
    builder.append(key);
    builder.append('=');
    builder.append(message);

    document.setContent(builder.toString());

    this.oldcore.getMockXWiki().saveDocument(document, "", this.oldcore.getXWikiContext());

    setBundles(document.getFullName());
  }
 private void loadLanguages() {
   mLocaleAdapter =
       com.android.internal.app.LocalePicker.constructAdapter(
           getActivity(), R.layout.locale_picker_item, R.id.locale);
   mInitialLocale = Locale.getDefault();
   mCurrentLocale = mInitialLocale;
   mAdapterIndices = new int[mLocaleAdapter.getCount()];
   int currentLocaleIndex = 0;
   String[] labels = new String[mLocaleAdapter.getCount()];
   for (int i = 0; i < mAdapterIndices.length; i++) {
     com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo =
         mLocaleAdapter.getItem(i);
     Locale localLocale = localLocaleInfo.getLocale();
     if (localLocale.equals(mCurrentLocale)) {
       currentLocaleIndex = i;
     }
     mAdapterIndices[i] = i;
     labels[i] = localLocaleInfo.getLabel();
   }
   mLanguagePicker.setDisplayedValues(labels);
   mLanguagePicker.setMaxValue(labels.length - 1);
   mLanguagePicker.setValue(currentLocaleIndex);
   mLanguagePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
   mLanguagePicker.setOnValueChangedListener(
       new LocalePicker.OnValueChangeListener() {
         public void onValueChange(LocalePicker picker, int oldVal, int newVal) {
           setLocaleFromPicker();
         }
       });
 }
  protected void validateDDMFormFieldPropertyValue(
      String fieldName,
      String propertyName,
      LocalizedValue propertyValue,
      Set<Locale> ddmFormAvailableLocales,
      Locale ddmFormDefaultLocale)
      throws DDMFormValidationException {

    if (!ddmFormDefaultLocale.equals(propertyValue.getDefaultLocale())) {
      throw new DDMFormValidationException(
          "Invalid default locale set for property \""
              + propertyName
              + "\" of field name "
              + fieldName);
    }

    if (!ddmFormAvailableLocales.equals(propertyValue.getAvailableLocales())) {

      throw new DDMFormValidationException(
          "Invalid available locales set for property \""
              + propertyName
              + "\" of field name "
              + fieldName);
    }
  }
예제 #20
0
 @Override
 public Locale findClosestMatch(Set<Locale> fromSet, Locale forLocale) {
   String variant = forLocale.getDisplayVariant();
   String country = forLocale.getCountry();
   String language = forLocale.getLanguage();
   Locale[] c = new Locale[4];
   if (null != variant && !variant.isEmpty()) {
     c[0] = forLocale;
   }
   if (null != country && !country.isEmpty()) {
     c[1] = new Locale(language, country);
   }
   if (null != language && !language.isEmpty()) {
     c[2] = new Locale(language);
   }
   c[3] = Locale.ROOT;
   for (Locale candidateLocale : c) {
     if (fromSet.contains(candidateLocale)) {
       return candidateLocale;
     }
   }
   // This code intentionally uses Locale.getDefault()
   // in order to behave in the same was as the default
   // resource bundle locale search mechanism.
   // source: http://docs.oracle.com/javase/tutorial/i18n/resbundle/concept.html
   Locale systemDefaultLocale = Locale.getDefault();
   if (!systemDefaultLocale.equals(forLocale)) {
     return findClosestMatch(fromSet, systemDefaultLocale);
   }
   return null;
 }
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    AtmosphereResponse that = (AtmosphereResponse) o;

    if (contentLength != that.contentLength) return false;
    if (delegateToNativeResponse != that.delegateToNativeResponse) return false;
    if (destroyable != that.destroyable) return false;
    if (headerHandled != that.headerHandled) return false;
    if (isCommited != that.isCommited) return false;
    if (status != that.status) return false;
    if (asyncIOWriter != null
        ? !asyncIOWriter.equals(that.asyncIOWriter)
        : that.asyncIOWriter != null) return false;
    if (atmosphereRequest != null
        ? !atmosphereRequest.equals(that.atmosphereRequest)
        : that.atmosphereRequest != null) return false;
    if (charSet != null ? !charSet.equals(that.charSet) : that.charSet != null) return false;
    if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null)
      return false;
    if (cookies != null ? !cookies.equals(that.cookies) : that.cookies != null) return false;
    if (headers != null ? !headers.equals(that.headers) : that.headers != null) return false;
    if (locale != null ? !locale.equals(that.locale) : that.locale != null) return false;
    if (response != null ? !response.equals(that.response) : that.response != null) return false;
    if (statusMessage != null
        ? !statusMessage.equals(that.statusMessage)
        : that.statusMessage != null) return false;
    if (writeStatusAndHeader != null
        ? !writeStatusAndHeader.equals(that.writeStatusAndHeader)
        : that.writeStatusAndHeader != null) return false;

    return true;
  }
예제 #22
0
 /**
  * Returns a copy of this formatter with a new locale.
  *
  * <p>This instance is immutable and unaffected by this method call.
  *
  * @param locale the new locale, not null
  * @return a {@code DateTimeFormatter} based on this one with the requested locale, not null
  */
 public DateTimeFormatter withLocale(Locale locale) {
   Objects.requireNonNull(locale, "locale");
   if (locale.equals(this.locale)) {
     return this;
   }
   return new DateTimeFormatter(printerParser, locale, symbols);
 }
예제 #23
0
 private static ResourceBundle getBundleImpl(String bundleName, Locale locale, ClassLoader loader)
     throws MissingResourceException {
   if (bundleName != null) {
     ResourceBundle bundle;
     if (!locale.equals(Locale.getDefault())) {
       String localeName = locale.toString();
       if (localeName.length() > 0) {
         localeName = UNDER_SCORE + localeName;
       }
       if ((bundle = handleGetBundle(bundleName, localeName, false, loader)) != null) {
         return bundle;
       }
     }
     String localeName = Locale.getDefault().toString();
     if (localeName.length() > 0) {
       localeName = UNDER_SCORE + localeName;
     }
     if ((bundle = handleGetBundle(bundleName, localeName, true, loader)) != null) {
       return bundle;
     }
     throw new MissingResourceException(
         Messages.getString("luni.3A", bundleName, locale),
         bundleName + '_' + locale, // $NON-NLS-1$
         EMPTY_STRING);
   }
   throw new NullPointerException();
 }
예제 #24
0
 @Override
 public DateFieldMapper build(BuilderContext context) {
   fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
   if (!locale.equals(dateTimeFormatter.locale())) {
     dateTimeFormatter =
         new FormatDateTimeFormatter(
             dateTimeFormatter.format(),
             dateTimeFormatter.parser(),
             dateTimeFormatter.printer(),
             locale);
   }
   DateFieldMapper fieldMapper =
       new DateFieldMapper(
           buildNames(context),
           dateTimeFormatter,
           fieldType.numericPrecisionStep(),
           boost,
           fieldType,
           docValues,
           nullValue,
           timeUnit,
           ignoreMalformed(context),
           coerce(context),
           postingsProvider,
           docValuesProvider,
           similarity,
           normsLoading,
           fieldDataSettings,
           context.indexSettings(),
           multiFieldsBuilder.build(this, context),
           copyTo);
   fieldMapper.includeInAll(includeInAll);
   return fieldMapper;
 }
예제 #25
0
  public static Locale localeMatch(List<String> requestedLocales, List<Locale> availableLocales) {
    if (requestedLocales == null || availableLocales == null) {
      return null;
    }

    for (String requestedLocale : requestedLocales) {
      Locale reqInQuestion = LocaleUtils.toLocale(requestedLocale);
      List<Locale> lookupList = LocaleUtils.localeLookupList(reqInQuestion);

      for (Locale localeInQuestion : lookupList) {
        for (Locale availableLocale : availableLocales) {
          if (localeInQuestion.equals(availableLocale)) {
            return availableLocale;
          }
        }
      }

      for (Locale availableLocale : availableLocales) {
        if (reqInQuestion.getLanguage().equals(availableLocale.getLanguage())) {
          return availableLocale;
        }
      }
    }

    return null;
  }
예제 #26
0
  private static Locale _getSuperLocale(Locale locale) {
    String variant = locale.getVariant();

    if (variant.length() > 0) {
      return new Locale(locale.getLanguage(), locale.getCountry());
    }

    String country = locale.getCountry();

    if (country.length() > 0) {
      Locale priorityLocale = LanguageUtil.getLocale(locale.getLanguage());

      if ((priorityLocale != null) && !locale.equals(priorityLocale)) {
        return new Locale(priorityLocale.getLanguage(), priorityLocale.getCountry());
      }

      return LocaleUtil.fromLanguageId(locale.getLanguage(), false, true);
    }

    String language = locale.getLanguage();

    if (language.length() > 0) {
      return _blankLocale;
    }

    return null;
  }
예제 #27
0
 public int getIndex(Locale locale) {
   for (int i = 0; i < getLocales().length; i++) {
     if (locale.equals(getLocales()[i])) {
       return i;
     }
   }
   return 0;
 }
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      AdsBlockKey that = (AdsBlockKey) o;
      return locale.equals(that.locale) && name.equals(that.name);
    }
예제 #29
0
  /**
   * Attempts to find a matching locale based on <code>pref</code> and list of supported locales,
   * using the matching algorithm as described in JSTL 8.3.2.
   *
   * @param context the <code>FacesContext</code> for the current request
   * @param pref the preferred locale
   * @return the Locale based on pref and the matching alogritm specified in JSTL 8.3.2
   */
  protected Locale findMatch(FacesContext context, Locale pref) {

    Locale result = null;
    Iterator<Locale> it = context.getApplication().getSupportedLocales();
    while (it.hasNext()) {
      Locale supportedLocale = it.next();

      if (pref.equals(supportedLocale)) {
        // exact match
        result = supportedLocale;
        break;
      } else {
        // Make sure the preferred locale doesn't have country
        // set, when doing a language match, For ex., if the
        // preferred locale is "en-US", if one of supported
        // locales is "en-UK", even though its language matches
        // that of the preferred locale, we must ignore it.
        if (pref.getLanguage().equals(supportedLocale.getLanguage())
            && supportedLocale.getCountry().length() == 0) {
          result = supportedLocale;
        }
      }
    }
    // if it's not in the supported locales,
    if (null == result) {
      Locale defaultLocale = context.getApplication().getDefaultLocale();
      if (defaultLocale != null) {
        if (pref.equals(defaultLocale)) {
          // exact match
          result = defaultLocale;
        } else {
          // Make sure the preferred locale doesn't have country
          // set, when doing a language match, For ex., if the
          // preferred locale is "en-US", if one of supported
          // locales is "en-UK", even though its language matches
          // that of the preferred locale, we must ignore it.
          if (pref.getLanguage().equals(defaultLocale.getLanguage())
              && defaultLocale.getCountry().length() == 0) {
            result = defaultLocale;
          }
        }
      }
    }

    return result;
  }
예제 #30
0
 private boolean setLocale(Locale lang, boolean onActivate) {
   Locale[] available = WInputMethodDescriptor.getAvailableLocalesInternal();
   for (int i = 0; i < available.length; i++) {
     Locale locale = available[i];
     if (lang.equals(locale)
         ||
         // special compatibility rule for Japanese and Korean
         locale.equals(Locale.JAPAN) && lang.equals(Locale.JAPANESE)
         || locale.equals(Locale.KOREA) && lang.equals(Locale.KOREAN)) {
       if (isActive) {
         setNativeLocale(locale.toLanguageTag(), onActivate);
       }
       currentLocale = locale;
       return true;
     }
   }
   return false;
 }