MomentUtils { protected static String getLocaleName(final String gwtLocale) { final String locale = Optional.of(gwtLocale).get().toLowerCase().replace("_", "-"); if (locale.isEmpty() || "default".equals(locale)) { return "en"; } else { return locale; } }  static native void setMomentLocale(final String locale);  }
@Test public void testLocale() { assertEquals("en", MomentUtils.getLocaleName("default")); assertEquals("en", MomentUtils.getLocaleName("")); assertEquals("es", MomentUtils.getLocaleName("es")); assertEquals("fr", MomentUtils.getLocaleName("fr")); assertEquals("ja", MomentUtils.getLocaleName("ja")); assertEquals("pt-br", MomentUtils.getLocaleName("pt_BR")); assertEquals("zh-cn", MomentUtils.getLocaleName("zh_CN")); assertEquals("de", MomentUtils.getLocaleName("de")); }