user2143356
user2143356

Reputation: 5607

Getting full language support with Twitter buttons isn't possible

I'm trying to work out how to do full language control with Twitter because I have most of it, but I don't think it's possible in full. This isn't a newbe question, I think there's a big problem with Twitter.

So imagine I'm trying to set the French language and using this:

<a href="https://twitter.com/username" class="twitter-follow-button">View Profile</a>

I have done this:

(1) Set the language in the document

<html lang="fr" />

(2) Added the ?lang=fr parameter so that if JavaScript is off then the fallback (just a text link) opens the profile with the correct language:

<a href="https://twitter.com/username?lang=fr" class="twitter-follow-button">View Profile</a>

(3) Added the data-lang="fr" attribute as well:

<a href="https://twitter.com/username?lang=fr" data-lang="fr" class="twitter-follow-button">View Profile</a>

--

So the questions:

(1) Everything works except if JavaScript runs and you click to open a page on twitter.com it never uses the language. So, basically you could have a French website with French language, French Twitter buttons, but when you click a button it always uses English language on twitter.com (unless you turn off JavaScript).

Is it not possible for links to open twitter.com?lang=fr

(2) Is there not an easy way to do this all in one place? In Facebook you just call the API script by selecting the language you want, but that doesn't seem possible with Twitter and it seems very time consuming appending all the extras just to get a different language.

Upvotes: 0

Views: 163

Answers (1)

Lee
Lee

Reputation: 10603

  1. Twitter will determine the language for it's own website when no language is specified (as you'd expect!). If you want to force a language on twitter you need to set the lang attribute in the url such as: http://www.twitter.com/Username?lang=fr

  2. You can only use URL or data attributes to specify a language. Facebook will detect the language settings of the website its widget is embedded in, twitter won't. I don't know how the facebook button works, but on face value, i think twitter is right with this one. If a Spanish person was viewing my English website, I'd prefer twitter to be Spanish still even though my site is English. If i really want to force a specific language i can do, but i wouldn't normally want to force my viewers to a specific language unless it's out of my reasonable control.

If it really annoys you, and your tags aren't rendered dynamically (i.e. the element isnt loaded after DOM ready), you could just run a piece of javascript to detect twitter buttons and append your chosen language to the URLs/data attributes.

Upvotes: 1

Related Questions