/** * Creates a locale id for a given language tag. * <p>This method is the same as calling <code>new LocaleId(tag)</code>. * @param tag the language tag. * @return a new locale id for the given language tag. */ public static LocaleId getLocaleId (String tag) { return new LocaleId(tag); }
/** * Creates a new LocaleId from a locale identifier (and validate it). * Calling this method is the same as calling <code>new LocaleId(locId, true);</code> * @param locId the locale identifier to use (it will be normalized). * @return a new localeId object from the given identifier. * @throws IllegalArgumentException if the argument is invalid. */ static public LocaleId fromString(String locId) { final LocaleId result = new LocaleId(okapiLocaleToULocale(locId)); result.originalLocId = locId; return result; }
/** * Creates a locale id for a given LCID value. * @param lcid the LCID to lookup. * @return a new locale id for the given LCID value. */ public static LocaleId getLocaleId (int lcid) { return new LocaleId(getTag(lcid)); }
/** * Validate a Zanata localeId to BCP-47 and return an equivalent Okapi LocaleId * @param zanataLocale Zanata LocaleId to convert * @return Okapi LocaleId, as-is to preserve case (no normalization) * @throws IllegalArgumentException on validation failure */ public static @Nonnull LocaleId toOkapiLocale(@Nonnull org.zanata.common.LocaleId zanataLocale) throws IllegalArgumentException { LocaleId.fromBCP47(zanataLocale.getId()); return new LocaleId(zanataLocale.getId(), false); }
/** * Helper method. */ private void setLocale(boolean excludeMode, String language, String region, String userPart) { if (Util.isEmpty(language)) return; if (Util.isEmpty(region)) return; if (Util.isEmpty(userPart)) return; if (excludeMode) exclude(new LocaleId(language, region, userPart)); else include(new LocaleId(language, region, userPart)); }
final LocaleId result = new LocaleId(ulocale); result.originalLocId = langtag; return result;
final LocaleId result = new LocaleId(builder.build()); result.originalLocId = locId; return result;