Is there anyway to set the language of disqus form on the drupal site instead of disqus site. Like this it could be dynamically switched to any language on a multilang website.

Comments

heyyo’s picture

found this link on disqus developper which provides this new functionnality:
http://groups.google.com/group/disqus-dev/browse_thread/thread/ed6cd66c3...

rnyberg’s picture

I am attempting to get our site work with that language modifier as well. Any info you have on it appreciated!

robloach’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new3.3 KB

Here it is for Drupal 7... Once in we could port it to Drupal 6! Thanks for the help on this, rnyberg.

robloach’s picture

StatusFileSize
new3.1 KB

Whoops, don't want debugging info in there.

robloach’s picture

Status: Needs review » Fixed

Thanks!!!! Uses the $language->language variable, so it's based on the content that's being used. It's a toggle in the Disqus administration in case you'd rather just use the one provided by Disqus.

Drupal 6: http://drupal.org/cvs?commit=497528
Drupal 7: http://drupal.org/cvs?commit=497510

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

emattias’s picture

Status: Closed (fixed) » Needs work

Unfortunately disqus doesn't always use the same language codes as Drupal does. For example the language code for swedish in drupal is "sv" and in Disqus it's "sv_SE". So if I enable localization support on my multi lang (en/sv) site disqus won't work at allon teh swedish part of the site since it sends the language "sv" to disqus which it doesn't know.

My 2 proposed solutions are:

1. "Translate" the language code from Drupal lang codes to Disqus lang codes before sending it to disqus, which makes it transparently just work. Porhaps this could be done when saving the disqus settings form and/or language settings form and save it to a variable?

OR

2. List the enabled languages on the site in the disqus settings form and let the admin match it to a disqus language code.

For my site I overrided the Drupal.behaviors.disqus in js and changed the line:

this.language = disqus.language;

to

this.language = disqus.language == 'sv' ? 'sv_SE' : disqus.language;

I found the lang codes by inspecting the language select box on the general settings page on disqus.com. Heres that source code(note the value attribute on the option tags):

<select name="forum_language"><option value="en">English</option><option value="ar">Arabic</option><option value="af">Afrikaans</option><option value="sq">Albanian</option><option value="hy">Armenian</option><option value="az">Azerbaijani</option><option value="eu">Basque</option><option value="ben">Bengali</option><option value="bg">Bulgarian</option><option value="zh">Chinese (Simplified)</option><option value="zh_HANT">Chinese (Traditional)</option><option value="hr">Croatian</option><option value="cs">Czech</option><option value="da">Danish</option><option value="nl">Dutch</option><option value="eo">Esperanto</option><option value="et">Estonian</option><option value="fi">Finnish</option><option value="fr">French</option><option value="ka">Georgian</option><option value="de_formal">German (formal)</option><option value="de_inf">German (informal)</option><option value="el">Greek</option><option value="he">Hebrew</option><option value="hu">Hungarian</option><option value="it">Italian</option><option value="is">Icelandic</option><option value="id">Indonesian</option><option value="ja">Japanese</option><option value="ko">Korean</option><option value="lo">Laotian</option><option value="la">Latin</option><option value="lv">Latvian</option><option value="lb">Letzeburgesch</option><option value="lt">Lithuanian</option><option value="mk">Macedonian</option><option value="ms">Malay (Bahasa Melayu)</option><option value="nb">Norwegian (Bokmål)</option><option value="fa">Persian</option><option value="pl">Polish</option><option value="pt_BR">Portuguese (Brazil)</option><option value="pt_EU">Portuguese (European)</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sr_CYRL">Serbian (Cyrillic)</option><option value="sr_LATIN">Serbian (Latin)</option><option value="sk">Slovak</option><option value="sl">Slovenian</option><option value="es_AR">Spanish (Argentina)</option><option value="es_MX">Spanish (Mexico)</option><option value="es_ES">Spanish (Spain)</option><option selected="" value="sv_SE">Swedish</option><option value="tr">Turkish</option><option value="th">Thai</option><option value="uk">Ukrainian</option><option value="vi">Vietnamese</option></select>
SilviaT’s picture

sub

igalarza’s picture

Hello, I've just configured and enabled Disqus in my multilingual web site, following the instructions in #7 and is working fine. This is the code that I've added:

  // Provide alternate language support if desired.
  if (variable_get('disqus_localization', FALSE)) {
    global $language;
    switch ($language->language) {
      case 'es': $disqus['language'] = 'es_ES' ;
      break ;
      case 'de': $disqus['language'] = 'de_formal' ;
      break ;
      case 'bs': $disqus['language'] = 'hr' ;
      break ;
      default: $disqus['language'] = $language->language;
    }
  }

I've not created a patch because my code is incomplete and maybe incorrect, but I hope you find it useful.

Kind regards.

barraponto’s picture

Title: Support for multilang websites » Proper locale support
Category: feature » bug

The code in the last patch have been committed for a year now. Yet there is still a bug in that Disqus localization doesn't follow any ISO recommendation. Drupal follows ISO 3166-1 alpha 2, see includes/iso.inc.

The best case solution would be for Disqus to move to any ISO standard so we can just map the values. Since we shouldn't rely on that, I guess the best way to move forward now would be to implement the mapping manually, as a fallback.

barraponto’s picture

EDIT: the ISO standard followed by Drupal is ISO 639-1.
ISO 3166-1 is also followed, but for country codes.

barraponto’s picture

Status: Needs work » Needs review
StatusFileSize
new2.97 KB

Attached is a patch that checks the Disqus language support and uses the proper Disqus code.

barraponto’s picture

Re-rolling to strip trailing whitespace from patch.

alexweber’s picture

Status: Needs review » Reviewed & tested by the community

Tested and works for me!

Thanks barraponto for this patch.

barraponto’s picture

Priority: Normal » Major

It actually breaks the module for some languages.
Is this critical material?

Cyclodex’s picture

Patch looks good but it is not working for me, I debugged until config var and there it is set the correct language now.
(I need German translation and de_formal should be supported on disqus...)

Question: Do you have enabled the setting "2012 Feature" on Disqus.com ?

I will have to check if the API changed, its just not working over here :(

barraponto’s picture

Assigned: Unassigned » barraponto

Gotta test whether it's still needed with latest disqus. I've been using this patch with disqus 2012, no issues.

Cyclodex’s picture

Do you have different languages on you site ?
Or are you just using the default language which can be selected over at disqus.com ?

Cyclodex’s picture

Okey, it is the Feature 2012!
Disable it on the disqus.com account/settings and it will work.

Seems they have to implement language support in 2012 Version or something is wrongly documented.
It does not work for me.

robloach’s picture

Looks pretty good to me, is there anything holding this back from being committed?

Cyclodex’s picture

You mean the patch looks fine yea? What about the Feature 2012? That is also not working for you, is it ? You also have to disable the Feature 2012 , correct ?

barraponto’s picture

I've tested it thoroughly. "Localization Support" is ignored if Disqus 2012 features are enabled for your site.

barraponto’s picture

I guess it's an upstream issue. I've pinged disqus support on this, awaiting responses.

Cyclodex’s picture

I made a comment on a page, after someone else also commented it is not working, but now I can not find them anymore. Not sure if they removed them now.... :-/

barraponto’s picture

@Cyclodex is your bug related to locale issues? If it's unrelated, please open a new issue. And if you think it's an issue with the Disqus service (not the Drupal module), post it to their support forum: http://disqus.com/support .

Cyclodex’s picture

Alright, but I am not sure if
A: the Drupal module is not compatible with their Feature 2012 enabled settings.
or
B: They have an issue in general on the Feature 2012 Service regarding language.

Anyway is this module also some kind of maintained by disqus.com people or is this just an Drupal developer maintaining this module? ... Ah no, it looks like someone of Acquia is the maintainer.

barraponto’s picture

A) With 2012 features enabled, the module doesn't break, but it doesn't change the language either (will use the default set in Disqus.com).

B) I opened that issue, but I don't think their issue tracking is public :/

C) I'm just a Drupal developer. I stepped up to this issue because it affected my Brazilian blog. The mantainer is reachable from his user page, feel free to ping him.

lsolesen’s picture

Feature 2012 cannot be disabled once enabled: http://help.disqus.com/customer/portal/articles/526768-introducing-disqu....

There is a problem with Disqus and locale support when it is enabled (and all new accounts have it enabled). Therefore, this should either be postphoned until Disqus fixes it or be set as Needs work.

lsolesen’s picture

Status: Reviewed & tested by the community » Needs work
capellic’s picture

I tried using "Localization support", found this issue and ended up doing the brut force method via jQuery in my theme's JavaScript file. Thanks to all the comments above, I was able to get this done in 5 minutes. Here's my code:

(function($) {
	Drupal.behaviors.multilingual = {
		attach: function(context, settings) {
			if (context == document) {
				// Force language to ES if in that context
				if (settings.disqus.language == 'es') {
					settings.disqus.language = 'es_MX';
				}
			}
		}
	}
})(jQuery);

Note that "Localization support" also has be checked for this code to work.

xiukun.zhou’s picture

// Support chinese.
if(settings.disqus.language == 'zh-hans') {
   settings.disqus.language = 'zh';
}

#2120211: Drupal lancode not equal disqus lancode

  • Commit c60608e on 7.x-1.x, 8.x-1.x by RobLoach:
    #1054604 by heyyo, rnyberg and Rob Loach: Localization support.
    
    
pianomansam’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)

With commit c60608e, this appears to be fixed.