effectiveReadingProgression property

ReadingProgression get effectiveReadingProgression

Implementation

ReadingProgression get effectiveReadingProgression {
  if (readingProgression != ReadingProgression.auto) {
    return readingProgression;
  }

  // https://github.com/readium/readium-css/blob/develop/docs/CSS16-internationalization.md#missing-page-progression-direction
  if (languages.length != 1) {
    return ReadingProgression.ltr;
  }

  String language = languages.first.toLowerCase();

  if (language == "zh-hant" || language == "zh-tw") {
    return ReadingProgression.rtl;
  }

  // The region is ignored for ar, fa and he.
  language = language.split("-").first;
  if (["ar", "fa", "he"].contains(language)) {
    return ReadingProgression.rtl;
  }
  return ReadingProgression.ltr;
}