Closed trinity-1686a closed 4 years ago
Hey, sorry for delay.
Quick answer: I don't think it belongs to the scope of the library. I don't want to frustrate you, but it is also important to keep the project within its boundaries to keep it maintainable.
Theoretical possible solution would be to extract a crate that would be responsible for presenting languages. The feature that you asks would fit to this crate.
This was already once proposed on reddit, but I declined this idea, because it would be hard to come up with a set of languages, that his crate should support (there are thousand of languages exist!). Also that set would be a superset of the languages supported by whatlang.
I want to take time to think about all of this again.
Anyway, thanks for reporting.
Ok. I've made a commit that implement this for scripts here. It's not that long, but I can understand you wanting to keep this crate focused on its goal
It may not be easy to correctly satisfy requirements for japanese language (Katakana & Hiragana). As I just quickly figured out with google, the may write from right to left, from top down and even sometimes from left to right (just to illustrate that things can be complex :) ).
Regarding your change: it's not necessary to fork and patch the library.
You can extend it within your application by defining custom traits and implementing the traits for Script
. E.g.
trait ScriptDirection {
fn direction(&self) -> Direction;
}
impl ScriptDirection for whatlang::Script {
fn direction(&self) -> Direction {
match *self {
Script::Latin => Direction::Ltr,
...
}
}
}
I think something like this should work. You'll just need to import trait ScriptDirection
in modules where you want to use direction()
method.
the goal of the so called fork was to make a pr if this feature was wanted. If it's not, I'll integrate that directly in my project. If your mind is made on whether you want that, you can close this issue :wink:
I am closing the issue, since I believe it's out of the library scope.
Most western languages are read from left to right, however some languages (Persian, Arabic...) are read from right to left, which impact how they should be displayed. I would find useful if this crate could, in addition to detect languages, map a Language or a Script to the direction it should be displayed (which could be a simple enum
Direction::Ltr
orDirection::Rtl
for instance)