@Test public void testGetLanguage() { assertThat(new LocaleCode("en-US").getLanguage()).isEqualTo("en"); assertThat(new LocaleCode("en").getLanguage()).isEqualTo("en"); assertThat(new LocaleCode("zh-CN").getLanguage()).isEqualTo("zh-hans"); assertThat(new LocaleCode("zh-SG").getLanguage()).isEqualTo("zh-hans"); assertThat(new LocaleCode("zh-Hans-CN").getLanguage()).isEqualTo("zh-hans"); assertThat(new LocaleCode("zh-Hans").getLanguage()).isEqualTo("zh-hans"); assertThat(new LocaleCode("zh-HK").getLanguage()).isEqualTo("zh-hant"); assertThat(new LocaleCode("zh-MO").getLanguage()).isEqualTo("zh-hant"); assertThat(new LocaleCode("zh-TW").getLanguage()).isEqualTo("zh-hant"); assertThat(new LocaleCode("zh-Hant").getLanguage()).isEqualTo("zh-hant"); assertThat(new LocaleCode("zh-Hant-TW").getLanguage()).isEqualTo("zh-hant"); assertThat(new LocaleCode("zh-hant-TW").getLanguage()).isEqualTo("zh-hant"); assertThat(new LocaleCode("zh-hant-tw").getLanguage()).isEqualTo("zh-hant"); }
public @NotNull String getLanguage() { switch (id) { case "zh-cn": case "zh-hans": case "zh-sg": return "zh-hans"; case "zh-hk": case "zh-mo": case "zh-hant": case "zh-tw": return "zh-hant"; default: if (id.startsWith("zh-hans-")) return "zh-hans"; if (id.startsWith("zh-hant-")) return "zh-hant"; int pos = id.indexOf('-'); return pos < 0 ? id : id.substring(0, pos); } }
LocaleCode implements Serializable { public @NotNull String getLanguage() { switch (id) { case "zh-cn": case "zh-hans": case "zh-sg": return "zh-hans"; case "zh-hk": case "zh-mo": case "zh-hant": case "zh-tw": return "zh-hant"; default: if (id.startsWith("zh-hans-")) return "zh-hans"; if (id.startsWith("zh-hant-")) return "zh-hant"; int pos = id.indexOf('-'); return pos < 0 ? id : id.substring(0, pos); } } }
LocaleCode implements Serializable { public @NotNull String getLanguage() { switch (id) { case "zh-cn": case "zh-hans": case "zh-sg": return "zh-hans"; case "zh-hk": case "zh-mo": case "zh-hant": case "zh-tw": return "zh-hant"; default: if (id.startsWith("zh-hans-")) return "zh-hans"; if (id.startsWith("zh-hant-")) return "zh-hant"; int pos = id.indexOf('-'); return pos < 0 ? id : id.substring(0, pos); } } LocaleCode(@NotNull String localeCode); @SuppressWarnings("unused") protected  LocaleCode(); }
LocaleCode implements Serializable { public @NotNull String getLanguage() { switch (id) { case "zh-cn": case "zh-hans": case "zh-sg": return "zh-hans"; case "zh-hk": case "zh-mo": case "zh-hant": case "zh-tw": return "zh-hant"; default: if (id.startsWith("zh-hans-")) return "zh-hans"; if (id.startsWith("zh-hant-")) return "zh-hant"; int pos = id.indexOf('-'); return pos < 0 ? id : id.substring(0, pos); } } LocaleCode(@NotNull String localeCode); @SuppressWarnings("unused") protected  LocaleCode(); static LocaleCode fromJavaName(String localeName); @SuppressWarnings("null") @NotNull String toJavaName(); @NotNull String toString(); @NotNull String getLanguage(); @Size(max = 128) @NotNull String getId(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); }
LocaleCode implements Serializable { public @NotNull String getLanguage() { switch (id) { case "zh-cn": case "zh-hans": case "zh-sg": return "zh-hans"; case "zh-hk": case "zh-mo": case "zh-hant": case "zh-tw": return "zh-hant"; default: if (id.startsWith("zh-hans-")) return "zh-hans"; if (id.startsWith("zh-hant-")) return "zh-hant"; int pos = id.indexOf('-'); return pos < 0 ? id : id.substring(0, pos); } } LocaleCode(@NotNull String localeCode); @SuppressWarnings("unused") protected  LocaleCode(); static LocaleCode fromJavaName(String localeName); @SuppressWarnings("null") @NotNull String toJavaName(); @NotNull String toString(); @NotNull String getLanguage(); @Size(max = 128) @NotNull String getId(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); static final LocaleCode EN; static final LocaleCode EN_US; static final LocaleCode DE; static final LocaleCode FR; static final LocaleCode IT; static final LocaleCode ES; static final LocaleCode JA; static final LocaleCode KO; static final LocaleCode PT; static final LocaleCode RU; static final LocaleCode ZH_HANS; static final LocaleCode ZH_HANT; }