Class LocaleUtils
java.lang.Object
org.vaadin.addons.componentfactory.schedulexcalendar.util.LocaleUtils
Utility class for working with
Locale objects.
This class provides methods to:
- Convert
Localeto Schedule-X compatible language tags (e.g., "en-US", "fr-FR") - Validate that a given
Localeis supported by Schedule-X - Handle edge cases like Serbian with script variants ("sr-Latn-RS", "sr-RS")
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisSupported(Locale locale) Checks whether the givenLocaleis supported by Schedule-X.static StringtoScheduleXLocale(Locale locale) Converts the givenLocaleto a Schedule-X compatible language tag (e.g., "en-US", "fr-FR").static voidvalidateLocale(Locale locale) Validates whether the givenLocaleis supported by Schedule-X.
-
Constructor Details
-
LocaleUtils
public LocaleUtils()
-
-
Method Details
-
validateLocale
Validates whether the givenLocaleis supported by Schedule-X.If the locale is not supported, throws an
IllegalArgumentExceptionwith an informative message.- Parameters:
locale- theLocaleto validate- Throws:
IllegalArgumentException- if the locale is not supported by Schedule-X
-
toScheduleXLocale
Converts the givenLocaleto a Schedule-X compatible language tag (e.g., "en-US", "fr-FR").Special handling is included for Serbian to differentiate between Latin and Cyrillic scripts.
- Parameters:
locale- theLocaleto convert (must not benull)- Returns:
- a language tag string compatible with Schedule-X (e.g., "en-US")
-
isSupported
Checks whether the givenLocaleis supported by Schedule-X.- Parameters:
locale- theLocaleto check- Returns:
trueif the locale is supported,falseotherwise
-