Package com.oorian.i18n
Class DirectionResolver
java.lang.Object
com.oorian.i18n.DirectionResolver
Resolves text direction (LTR/RTL) from a
Locale.
Maintains a set of known right-to-left language codes and provides methods to
determine the appropriate TextDirection for any locale. This is used to set
the HTML dir attribute and apply directional CSS.
Known RTL languages: Arabic, Hebrew, Persian (Farsi), Urdu, Yiddish, Syriac, Thaana (Dhivehi), N'Ko, and Samaritan.
Usage:
// Check the current locale
TextDirection dir = DirectionResolver.resolve(OorianLocale.get());
// → TextDirection.RTL for Arabic, TextDirection.LTR for English
// Quick RTL check
if (DirectionResolver.isRtl(OorianLocale.get()))
{
// Apply RTL-specific layout
}
// Get direction for the current thread's locale
TextDirection dir = DirectionResolver.resolveCurrentLocale();
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetHtmlDir(Locale locale) Returns the HTMLdirattribute value for the given locale.Returns an unmodifiable set of all known RTL language codes.static booleanChecks whether the current thread's locale uses a right-to-left script.static booleanChecks whether the given locale uses a right-to-left script.static TextDirectionResolves the text direction for the given locale.static TextDirectionResolves the text direction for the current thread's locale.
-
Method Details
-
resolve
Resolves the text direction for the given locale.- Parameters:
locale- the locale to check- Returns:
TextDirection.RTLif the locale's language is right-to-left,TextDirection.LTRotherwise
-
resolveCurrentLocale
Resolves the text direction for the current thread's locale.Uses
OorianLocale.get()to determine the active locale.- Returns:
- the text direction for the current locale
-
isRtl
Checks whether the given locale uses a right-to-left script.- Parameters:
locale- the locale to check- Returns:
trueif the locale is RTL
-
isCurrentLocaleRtl
public static boolean isCurrentLocaleRtl()Checks whether the current thread's locale uses a right-to-left script.- Returns:
trueif the current locale is RTL
-
getHtmlDir
Returns the HTMLdirattribute value for the given locale.Convenience method equivalent to
resolve(locale).getValue().- Parameters:
locale- the locale to check- Returns:
"rtl"or"ltr"
-
getRtlLanguages
Returns an unmodifiable set of all known RTL language codes.- Returns:
- the set of RTL language codes (ISO 639)
-