isRtlLanguage method

bool isRtlLanguage()

الكشف الذكي عن اللغات والنصوص العربية Smart detection for RTL languages and Arabic texts

Implementation

bool isRtlLanguage() {
  // إذا كان النص في القائمة المحددة مسبقاً
  if (rtlLang.contains(this)) return true;

  // إذا كان نصاً إسلامياً باللغة العربية
  if (_isArabicIslamicText()) return true;

  // إذا كان أكثر من 70% من النص يحتوي على أحرف RTL
  if (length > 0) {
    final rtlCharCount =
        split('').where((char) => char._containsRtlCharacters()).length;
    final rtlPercentage = rtlCharCount / length;
    if (rtlPercentage > 0.7) return true;
  }

  // إذا كان يحتوي على أحرف عربية أو فارسية أو عبرية
  return _containsRtlCharacters();
}