Package com.google.gwt.i18n.shared

Examples of com.google.gwt.i18n.shared.GwtLocale


      throw error(logger, e.getMessage());
    }

    // generated implementations for interface X will be named X_, X_en,
    // X_en_CA, etc.
    GwtLocale generatedLocale = resourceList.findLeastDerivedLocale(locale);
    String localeSuffix = String.valueOf(ResourceFactory.LOCALE_SEPARATOR);
    localeSuffix += generatedLocale.getAsString();
    // Use _ rather than "." in class name, cannot use $
    String resourceName = targetClass.getName().replace('.', '_');
    String className = resourceName + localeSuffix;
    PrintWriter pw = context.tryCreate(logger, packageName, className);
    if (pw != null) {
View Full Code Here


      }
      writer.println("  };");
      writer.println("}-*/;");
      writer.commit(logger);
    }
    GwtLocale locale = LocaleUtils.getCompileLocale();
    String className = targetClass.getName().replace('.', '_') + "_"
        + locale.getAsString();
    Set<GwtLocale> runtimeLocales = LocaleUtils.getRuntimeLocales();
    if (!runtimeLocales.isEmpty()) {
      className += "_runtimeSelection";
    }

View Full Code Here

      List<GwtLocale> searchList = locale.getCompleteSearchList();
      Map<GwtLocale, Integer> derivedIndex = new HashMap<GwtLocale, Integer>();
      for (int i = 0; i < searchList.size(); ++i) {
        derivedIndex.put(searchList.get(i), i);
      }
      GwtLocale best = LocaleUtils.getLocaleFactory().getDefault();
      int bestIdx = Integer.MAX_VALUE;
      for (int i = 0; i < list.size(); ++i) {
        GwtLocale matchLocale = list.get(i).getMatchLocale();
        Integer wrappedIdx = derivedIndex.get(matchLocale);
        if (wrappedIdx == null) {
          assert false : "Locale " + matchLocale + " not in searchlist "
              + searchList;
          continue;
View Full Code Here

    assert CURRENCY_LIST.equals(typeName);
    TypeOracle typeOracle = context.getTypeOracle();

    PropertyOracle propertyOracle = context.getPropertyOracle();
    LocaleUtils.init(logger, propertyOracle);
    GwtLocale locale = LocaleUtils.getCompileLocale();
    Set<GwtLocale> runtimeLocales = LocaleUtils.getRuntimeLocales();

    JClassType targetClass;
    try {
      targetClass = typeOracle.getType(typeName);
View Full Code Here

     * precede superclasses. Therefore, we iterate backwards to ensure that
     * superclasses are always generated first.
     */
    String lastDefaultCurrencyCode = null;
    for (int i = searchList.size(); i-- > 0;) {
      GwtLocale search = searchList.get(i);
      LocalizedProperties newExtra = getProperties(CURRENCY_EXTRA_PREFIX,
          search);
      if (newExtra != null) {
        currencyExtra = newExtra;
      }
View Full Code Here

      SelectionProperty localeProp
          = propertyOracle.getSelectionProperty(logger, PROP_LOCALE);
      String localeName = localeProp.getCurrentValue();
      SortedSet<String> localeValues = localeProp.getPossibleValues();

      GwtLocale newCompileLocale = factory.fromString(localeName);
      if (newCompileLocale.equals(compileLocale)) {
        return;
      }
      compileLocale = newCompileLocale;
      allLocales.clear();
      allCompileLocales.clear();
      runtimeLocales.clear();
      for (String localeValue : localeValues) {
        allCompileLocales.add(factory.fromString(localeValue));
      }
      allLocales.addAll(allCompileLocales);
     
      ConfigurationProperty prop
          = propertyOracle.getConfigurationProperty(PROP_RUNTIME_LOCALES);
      List<String> rtLocaleNames = prop.getValues();
      if (rtLocaleNames != null) {
        for (String rtLocale : rtLocaleNames) {
          GwtLocale locale = factory.fromString(rtLocale);
          // TODO(jat): remove use of labels
          existingLocales:
          for (GwtLocale existing : allCompileLocales) {
            for (GwtLocale alias : existing.getAliases()) {
              if (!alias.isDefault() && locale.inheritsFrom(alias)
                  && locale.usesSameScript(alias)) {
                allLocales.add(locale);
                break existingLocales;
              }
            }
          }
          if (!compileLocale.isDefault()
              && locale.inheritsFrom(compileLocale)
              && locale.usesSameScript(compileLocale)) {
            // TODO(jat): don't include runtime locales which also inherit
            // from a more-specific compile locale than this one
            runtimeLocales.add(locale);
          }
        }
View Full Code Here

    List<GwtLocale> locales = bundleLocale.getCompleteSearchList();
    List<JClassType> classes = new ArrayList<JClassType>();
    Set<JClassType> seenClasses = new IdentityHashSet<JClassType>();
    Map<ClassLocale, AnnotationsResource> annotations = new HashMap<ClassLocale, AnnotationsResource>();
    GwtLocaleFactory factory = LocaleUtils.getLocaleFactory();
    GwtLocale defaultLocale = factory.getDefault();
    walkInheritanceTree(logger, topClass, factory, defaultLocale, classes,
        annotations, seenClasses, isConstants);
    // TODO(jat): handle explicit subinterface with other locales -- ie:
    // public interface Foo_es_MX extends Foo { ... }
    ResourceList allResources = new ResourceList();
View Full Code Here

        DefaultLocale defLocaleAnnot = getClassAnnotation(clazz,
            DefaultLocale.class);
        if (defLocaleAnnot != null) {
          defLocaleValue = defLocaleAnnot.value();
        }
        GwtLocale defLocale = LocaleUtils.getLocaleFactory().fromString(
            defLocaleValue);
        if (!defLocale.isDefault()) {
          key = new ClassLocale(clazz, defLocale);
          annotations.put(key, resource);
        }
      }
    } catch (AnnotationsError e) {
View Full Code Here

      }
    } catch (BadPropertyValueException e) {
      // if we don't have locale properties defined, just return a basic one
      logger.log(TreeLogger.WARN,
          "Unable to get locale properties, using defaults", e);
      GwtLocale defaultLocale = factory.fromString("default");
      Set<GwtLocale> allLocales = new HashSet<GwtLocale>();
      allLocales.add(defaultLocale);
      return new LocaleUtils(defaultLocale, allLocales, allLocales,
          Collections.<GwtLocale>emptySet());
    }
View Full Code Here

    return factory;
  }

  private static LocaleUtils createInstance(TreeLogger logger,
      SelectionProperty localeProp, ConfigurationProperty prop) {
    GwtLocale compileLocale = null;
    Set<GwtLocale> allLocales = new HashSet<GwtLocale>();
    Set<GwtLocale> allCompileLocales = new HashSet<GwtLocale>();
    Set<GwtLocale> runtimeLocales = new HashSet<GwtLocale>();
    String localeName = localeProp.getCurrentValue();
    SortedSet<String> localeValues = localeProp.getPossibleValues();

    GwtLocaleFactory factoryInstance = getLocaleFactory();
    GwtLocale newCompileLocale = factoryInstance.fromString(localeName);
    compileLocale = newCompileLocale;
    for (String localeValue : localeValues) {
      allCompileLocales.add(factoryInstance.fromString(localeValue));
    }
    allLocales.addAll(allCompileLocales);

    List<String> rtLocaleNames = prop.getValues();
    if (rtLocaleNames != null) {
      for (String rtLocale : rtLocaleNames) {
        GwtLocale locale = factoryInstance.fromString(rtLocale);
        // TODO(jat): remove use of labels
        existingLocales:
        for (GwtLocale existing : allCompileLocales) {
          for (GwtLocale alias : existing.getAliases()) {
            if (!alias.isDefault() && locale.inheritsFrom(alias)
                && locale.usesSameScript(alias)) {
              allLocales.add(locale);
              break existingLocales;
            }
          }
        }
        if (!compileLocale.isDefault()
            && locale.inheritsFrom(compileLocale)
            && locale.usesSameScript(compileLocale)) {
          // TODO(jat): don't include runtime locales which also inherit
          // from a more-specific compile locale than this one
          runtimeLocales.add(locale);
        }
      }
View Full Code Here

TOP

Related Classes of com.google.gwt.i18n.shared.GwtLocale

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.