Skip to content

Add locale_is_right_to_left polyfill #527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from

Conversation

alexander-schranz
Copy link

@alexander-schranz alexander-schranz force-pushed the feature/locale_is_right_to_lef branch from 30b4e10 to beacebd Compare May 26, 2025 11:33
@@ -33,4 +34,8 @@ public static function get_exception_handler(): ?callable

return $handler;
}

public static function locale_is_right_to_left(string $locale): bool {
return (bool) preg_match('/^(?:ar|he|fa|ur|ps|sd|ug|ckb|yi|dv|ku_arab|ku-arab)(?:[_-].*)?$/i', $locale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right implementation. What is right to left is a script, not a language. And locales might specify a script explicitly which is not the most likely script.

Copy link
Author

@alexander-schranz alexander-schranz May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, any suggestions? Sadly the original code does not help here: unicode-org/icu@53dcbe6

  • A script is right-to-left according to the CLDR script metadata
  • which corresponds to whether the script's letters have Bidi_Class=R or AL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants