Wrap all english words with span in persian article

Hey Every Body,
i need to find all English words in my web site and wrap them with a span.

this is because my website is in Persian and whole website has rtl direction.

now i need to put English word inside <span style='direction:ltr'></span>.

So how do you define an english word, as opposed to a persian word?

That it contains the letters A-Z?

but what about 0-9? what about quotes, but not those inside tags, and about HTML entities that are written using a-z in the middle of persian text?

That’s why it’s not feasible to automate setting the direction. If it’s your website, then you need to set the markup of the page to correctly indicate what is there.

1 Like

Which was the point I was getting at :wink: Perhaps too obtusely.

Much like validating a phone number, trying to automate language is hard. If there isn’t a pressing need to automate it, manually insert the tags.

1 Like

AFAIK, the is no single “persian” any more so than there’s a single “english”. There is Farsi, Dari, Tajiki, and likely others.

That said, I think a regex using word boundary and a-zA-Z could work though it would need to be tested and refined (eg. 0-9 too?) i.e. easier to match against known English than to match against possible English.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.