Skip to content
This repository has been archived by the owner on Feb 27, 2018. It is now read-only.

Detect RTL text input and style appropriately #120

Open
tommorris opened this issue Oct 27, 2011 · 0 comments
Open

Detect RTL text input and style appropriately #120

tommorris opened this issue Oct 27, 2011 · 0 comments

Comments

@tommorris
Copy link
Member

Fairly niche use case (and I don't expect anyone to be crazy enough to implement it other than me), but useful to enable international use: detect Hebrew and Arabic text input and then style the display so that those text fields are aligned right.

Rough idea how to implement this:

Take the string, use the .mb_chars method that Rails mixes into strings, then check to see that whether 50% of the characters or more are in any of the following ranges:

Hebrew - U+05D0 to U+05EA, U+05F0 to U+05F2, U+05BE, U+05C0, U+05C3, U+05F3, U+05F4, U+05B0 to U+05C4, U+0591 to U+05AF.

Arabic - U+0600 to U+06FF, U+0750 to U+077F, U+FB50 to U+FDFF, U+FE70 to U+FEFF, U+10E60 to U+10E7F.

If so, set a flag on the text that makes it so it is displayed with a dir attribute set to "rtl". Style appropriately.

@ghost ghost assigned tommorris Oct 27, 2011
@tommorris tommorris removed their assignment Aug 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant