Package com.google.gwt.i18n.shared

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


        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


    TreeLogger logger = new FailErrorLogger();
    TypeOracle oracle = TypeOracleTestingUtils.buildStandardTypeOracleWith(
        logger, LOCALIZABLE, TEST, TEST_IW);
    JClassType test = oracle.findType("foo.Test");
    GwtLocaleFactory factory = new GwtLocaleFactoryImpl();
    GwtLocale locale = factory.fromString("he");
    String implClass = llc.linkWithImplClass(logger, test, locale);
    assertEquals("foo.Test_iw", implClass);
    oracle = TypeOracleTestingUtils.buildStandardTypeOracleWith(
        logger, LOCALIZABLE, TEST, TEST_HE);
    test = oracle.findType("foo.Test");
View Full Code Here

  private TypeOracle typeOracle;

  public void testNotOverridable() {
    LocalizableGenerator gen = new LocalizableGenerator();
    GwtLocale en = factory.fromString("en");
    Map<String, Set<GwtLocale>> localeMap = new TreeMap<String, Set<GwtLocale>>();
    String genClass = gen.generateRuntimeSelection(ctx, testClass,
        testClass.getQualifiedSourceName(), en, localeMap);
    assertEquals("foo.TestClass_en_runtimeSelection", genClass);
    StringWriter buf = bufs.get("TestClass_en_runtimeSelection");
View Full Code Here

    assertTrue("Should have delegated biff", genText.contains("biff("));
  }

  public void testRuntimeSelection() throws IOException {
    LocalizableGenerator gen = new LocalizableGenerator();
    GwtLocale en = factory.fromString("en");
    GwtLocale en_US = factory.fromString("en_US");
    GwtLocale en_US_POSIX = factory.fromString("en_US_POSIX");
    GwtLocale en_GB = factory.fromString("en_GB");
    GwtLocale en_PK = factory.fromString("en_PK");
    Map<String, Set<GwtLocale>> localeMap = new TreeMap<String, Set<GwtLocale>>();
    localeMap.put("foo.Test_en_US", new TreeSet<GwtLocale>(Arrays.asList(en_US, en_US_POSIX)));
    localeMap.put("foo.Test_en_GB", new TreeSet<GwtLocale>(Arrays.asList(en_GB)));
    localeMap.put("foo.Test_en", new TreeSet<GwtLocale>(Arrays.asList(en_PK)));
    String genClass = gen.generateRuntimeSelection(ctx, test, test.getQualifiedSourceName(), en,
View Full Code Here

    MessageInterpolator.Context context = new TestContext( descriptor );

    String expected = "kann nicht null sein";
    // TODO(nchalko) i18n
    //GwtLocaleFactory localeFactory = GWT.create(GwtLocaleFactory.class);
    GwtLocale german = null//localeFactory.fromComponents("de","","","");
    String actual = interpolator.interpolate(
        ( String ) descriptor.getAttributes().get( "message" ), context, german
    );
    assertEquals( actual, expected, "Wrong substitution" );
  }
View Full Code Here

    MessageInterpolator.Context context = new TestContext( descriptor );

    String messageInterpolatedWithNoLocale = interpolator.interpolate( messageTemplate, context );
    // TODO(nchalko) i18n
    //GwtLocaleFactory localeFactory = GWT.create(GwtLocaleFactory.class);
    GwtLocale defaultLocale = null; // localeFactory.getDefault();
    String messageInterpolatedWithDefaultLocale = interpolator.interpolate(
        messageTemplate, context,defaultLocale
    );

    assertEquals( messageInterpolatedWithNoLocale, messageInterpolatedWithDefaultLocale, "Wrong substitution" );
View Full Code Here

      pathSuffix = "/";
    } else {
      myClass = "DateTimeFormatInfoImpl" + localeSuffix(locale);
      pathSuffix = "/impl/cldr/";
    }
    GwtLocale parent = localeData.inheritsFrom(locale);
    PrintWriter pw = createOutputFile(clientShared + pathSuffix + myClass + ".java");
    printHeader(pw);
    pw.print("package com.google.gwt.i18n." + clientShared);
    // GWT now requires JDK 1.6, so we always generate @Overrides
    setOverrides(true);
    if (!locale.isDefault()) {
      pw.print(".impl.cldr");
    }
    pw.println(";");
    pw.println();
    pw.println("// DO NOT EDIT - GENERATED FROM CLDR AND ICU DATA");
    pw.println("//  cldrVersion=" + CLDRFile.GEN_VERSION);
    Map<String, String> map = localeData.getEntries("version", locale);
    for (Map.Entry<String, String> entry : map.entrySet()) {
      pw.println("//  " + entry.getKey() + "=" + entry.getValue());
    }
    pw.println();
    if (locale.isDefault()) {
      pw.println("/**");
      pw.println(" * Default implementation of DateTimeFormatInfo interface, "
          + "using values from");
      pw.println(" * the CLDR root locale.");
      pw.println(" * <p>");
      pw.println(" * Users who need to create their own DateTimeFormatInfo "
          + "implementation are");
      pw.println(" * encouraged to extend this class so their implementation "
          + "won't break when   ");
      pw.println(" * new methods are added.");
      pw.println(" */");
    } else {
      pw.println("/**");
      pw.println(" * Implementation of DateTimeFormatInfo for the \"" + locale + "\" locale.");
      pw.println(" */");
    }
    pw.print("public class " + myClass);
    if (locale.isDefault()) {
      pw.print(" implements " + DateTimeFormatInfo.class.getSimpleName());
    } else {
      pw.print(" extends ");
      pw.print(DateTimeFormatInfoImpl.class.getSimpleName());
      if (!parent.isDefault()) {
        pw.print('_');
        pw.print(parent.getAsString());
      }
    }
    pw.println(" {");

    // write AM/PM names
View Full Code Here

public class GwtLocaleTest extends TestCase {

  private GwtLocaleFactory factory = new GwtLocaleFactoryImpl();

  public void testAliases() {
    GwtLocale en = factory.fromString("en");
    List<GwtLocale> aliases = en.getAliases();
    assertEquals(aliases.get(0), en);
    GwtLocale enLatn = factory.fromString("en_Latn");
    assertContainsAndGetPosition(aliases, enLatn);
    assertTrue(en.usesSameScript(enLatn));
    assertTrue(enLatn.inheritsFrom(en));
    assertFalse(en.inheritsFrom(enLatn));
    assertFalse(en.inheritsFrom(en));
    GwtLocale pt = factory.fromString("pt");
    aliases = pt.getAliases();
    assertContainsAndGetPosition(aliases, factory.fromString("pt_BR"));
    GwtLocale iw = factory.fromString("iw");
    aliases = iw.getAliases();
    GwtLocale he = factory.fromString("he");
    assertEquals(aliases.get(0), he);
    assertContainsAndGetPosition(aliases, factory.fromString("iw_Hebr"));
    aliases = he.getAliases();
    assertContainsAndGetPosition(aliases, factory.fromString("iw_Hebr"));
    GwtLocale id = factory.fromString("id");
    aliases = id.getAliases();
    assertContainsAndGetPosition(aliases, factory.fromString("in"));
    GwtLocale mo = factory.fromString("mo");
    aliases = mo.getAliases();
    assertContainsAndGetPosition(aliases, factory.fromString("ro"));
    GwtLocale jv = factory.fromString("jv");
    aliases = jv.getAliases();
    assertContainsAndGetPosition(aliases, factory.fromString("jw"));
    GwtLocale ji = factory.fromString("ji");
    aliases = ji.getAliases();
    assertContainsAndGetPosition(aliases, factory.fromString("yi"));
  }
View Full Code Here

    aliases = ji.getAliases();
    assertContainsAndGetPosition(aliases, factory.fromString("yi"));
  }

  public void testCanonicalForm() {
    GwtLocale zhCN = factory.fromString("zh_CN");
    GwtLocale zhHansCN = factory.fromString("zh_Hans_CN");
    GwtLocale zhHant = factory.fromString("zh_Hant");
    GwtLocale zhTW = factory.fromString("zh_TW");
    GwtLocale zhHantTW = factory.fromString("zh_Hant_TW");
    GwtLocale zhHans = factory.fromString("zh_Hans");
    assertEquals(zhCN, zhHansCN.getCanonicalForm());
    assertEquals(zhTW, zhHantTW.getCanonicalForm());
    assertEquals(zhCN, zhHans.getCanonicalForm());
    assertEquals(zhTW, zhHant.getCanonicalForm());
    GwtLocale paPK = factory.fromString("pa_PK");
    GwtLocale paArabPK = factory.fromString("pa_Arab_PK");
    assertEquals(paPK, paArabPK.getCanonicalForm());
  }
View Full Code Here

    // Test equals against some non-GwtLocale class
    assertFalse(locales[0].equals(factory));
  }

  public void testDefault() {
    GwtLocale def1 = factory.getDefault();
    GwtLocale def2 = factory.fromString("default");
    assertSame(def1, def2);
    assertTrue(def1.isDefault());
    assertEquals("", def1.getLanguageNotNull());
    assertEquals("", def1.getScriptNotNull());
    assertEquals("", def1.getRegionNotNull());
    assertEquals("", def1.getVariantNotNull());
    GwtLocale def3 = factory.fromString(null);
    assertSame(def1, def3);
    GwtLocale def4 = factory.fromComponents("", "", "", "");
    assertSame(def1, def4);
  }
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.