Re: How to detect languages from (=> LTR vs RTL)
| From: | Ashley Sheridan | Date: | Tue, 07 Feb 2012 09:41:55 +0000 |
| Subject: | Re: How to detect languages from (=> LTR vs RTL) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316519@lists.php.net to get a copy of this message | ||
On Tue, 2012-02-07 at 09:37 +0100, Michelle Konzack wrote:
> Hi colleges and gurus,
>
> I coding a whole "web office" and one of my problems is "LTR vs RTL".
> If I have for exanple an E-Mail I use a
>
> <div style="direction:$DIRECTION">
> $SOME_TEXT
> </div>
>
> but HOW can I detect the type of $SOME_TEXT from within PHP, to set
> $DIRECTION? (RTL or LTR) correctly?
>
> And how can I do this with mixed Text (by line or entired paragraph)
> like:
>
> german <- must be LTR
> persian <------------------- must be RTL
> english <- must be LTR
> arabic <------------------- must be RTL
> french <- must be LTR
> jidisch <------------------- must be RTL
>
> Ayn Iranian (Moxhtar?), Arabs (Jasin?) or Jews (Dotan?) here which can
> help me please?
>
> Thanks, Greetings and nice Day/Evening
> Michelle Konzack
>
If I understand you correctly, you want to detect the language of a
string, or is it a substring within a string?
I'm not sure how easy that would be, given that some shorter sentences
might be common across languages, but I would hazard a guess that they
would also share the direction, so that shouldn't be a major issue.
I don't know of any way to do that, but could you possibly look for
certain characters in the string that would hint at the language? It
wouldn't work too well with mixed-language strings, but it might be
enough for what you want here?
--
Thanks,
Ash
http://www.ashleysheridan.co.uk