function isLocaleRTL(locale: string): boolean {
  const cachedRTL = cache.get(locale);
  if (cachedRTL) {
    return cachedRTL;
  }

  let isRTL = false;
  // $FlowFixMe
  if (Intl.Locale) {
    try {
      // $FlowFixMe
      const script = new Intl.Locale(locale).maximize().script;
      isRTL = rtlScripts.has(script);
    } catch {
      // RangeError: Incorrect locale information provided
      // Fallback to inferring from language
      const lang = locale.split('-')[0];
      isRTL = rtlLangs.has(lang);
    }
  } else {
    // Fallback to inferring from language
    const lang = locale.split('-')[0];
    isRTL = rtlLangs.has(lang);
  }

  cache.set(locale, isRTL);
  return isRTL;
}
Determine the writing direction of a locale