Closed advl closed 3 months ago
I think this might be a separate package that can be installed as an optional dependency (feature)
Thanks for posting this issue.
As you know, text direction is a property associated with a script, not a language. So I don't want to include it in this package dedicated to language codes.
Note that the Unicode Common Locale Data Repository (CLDR) maps languages to their scripts, and that the Babel package provides a Python interface to the CLDR.
from babel import Locale
from iso639 import Lang
def is_rtl(language_name):
language = Lang(language_name)
language_code = language.pt1 if language.pt1 else language.pt3
return Locale(language_code).text_direction == "rtl"
>>> is_rtl("Arabic")
True
>>> is_rtl("French")
False
Thank you for taking the time to answer and propose a solution. This is indeed helpful and solves my problem !
Hi,
First of all thank you for this library - it has been significantly helpful in a personal project I'm currently working on.
I would like to submit for consideration the addition of a rtl flag to the list of languages. This could take the shape of a simple boolean accessible on Lang instances. I believe we can trivially populate the values for the list of languages with an AI prompt.
For instance
or
I would use this feature to automatically set up css properties on my front-end.
If this feature can be considered, I can submit a pull request for it. I can see this feature would fall slightly outside of the strict scope of ISO639 mappings, so I would understand it being a reason for not implementing it. However, having this feature would help have one source of truth for language information.
Thank you for reading me !