Reputation: 63
I have a tricky scenario I'm dealing with while working on a site for a client. The website I am building has an English version and an Arabic version. The Arabic version of the site, of course, is displayed from right-to-left, since Arabic is read right-to-left.
I have built a jQuery Twitter app for the index page of both the English and Arabic versions. A requirement is that the client wants to be able to use one Twitter account and tweet in both English and Arabic. This creates a problem because in the Twitter ul
, I will need to simultaneously display English and Arabic text, without knowing what language to expect. Therefore I need a way to detect the language of the Tweets (retrieved by JSONP) and adjust the text direction of each li
.
Can anyone think of a good way to do this? Thanks for suggestions.
Upvotes: 2
Views: 810
Reputation: 1762
the Twitter API (https://dev.twitter.com/docs/api/1.1/get/search/tweets) shows that metadata contains "iso_language_code":
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
with this, you can check the "iso_language_code" for "en" or "ar" and format your content accordingly.
e.g.
<li lang="en">english text</li>
<li lang="ar" dir="rtl">arabic text</li>
Upvotes: 4