isRtl function
Returns true if locale represents a right-to-left (RTL) script.
Tests language subtags against known RTL scripts (Arabic, Hebrew, Persian, Urdu, etc.).
When locale is omitted, defaults to testing the active BloomI18n.instance.locale signal.
isRtl('ar-EG'); // true
isRtl('en-US'); // false
See also:
- getTextDirection, which returns a BloomTextDirection enum.
- dirAttribute, which produces an attribute map for element descriptors.
Implementation
bool isRtl([String? locale]) {
final loc = (locale ?? BloomI18n.instance.locale.value).replaceAll('_', '-').toLowerCase();
final lang = loc.split('-').first;
return _rtlLanguages.contains(lang);
}