Based on this patch for Tagadelic :
Tagadelic : http://drupal.org/node/339945

    case 'view':
      // Tagadelic API
      $tags = tagadelic_get_weighted_tags(array(variable_get('cumulus_vid', 1)), variable_get('cumulus_tagadelic_step', 6), variable_get('cumulus_tagadelic_limit', 24));
      $tags = tagadelic_sort_tags($tags);
+      if (module_exists("i18ntaxonomy")) {
+        i18ntaxonomy_localize_terms($tags);
+      }
      // theme tags for cumulus: tags tag, font size, link, encode
      $tags_formatted_flash = theme('cumulus_weighted', $tags);

Comments

broon’s picture

Hi there,

I was in need of this functionality, too, since we have a single vocabulary containing terms for all languages. In order to filter the terms to be shown depending on currently viewed language I did the following changes.

cumulus.module, around line 59 (Version info: cumulus.module,v 1.1.2.10 2009/04/14 09:04:58 lut4rp Exp) for sending current language as parameter:

+	global $language;
+	$clang = $language->language;
+	$tags = tagadelic_get_weighted_tags($vocs, variable_get('cumulus_tagadelic_step', 6), variable_get('cumulus_tagadelic_limit', 24), $clang);
-	$tags = tagadelic_get_weighted_tags($vocs, variable_get('cumulus_tagadelic_step', 6), variable_get('cumulus_tagadelic_limit', 24));
	$tags = tagadelic_sort_tags($tags);

tagadelic.module, around line 211 (Version info: tagadelic.module,v 1.40.2.4 2008/12/31 11:35:44 ber Exp) for getting the language parameter (defaulting to 'en') and including it by altering database query:

- function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) 
+ function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60, $lang_sel = 'en') 

{
  // build the options so we can cache multiple versions
  $options = implode($vids) .'_'. $steps .'_'. $size;
  
  // Check if the cache exists
+  $cache_name = 'tagadelic_cache_'. $options . '_' . $lang_sel; // include language in cache name
-  $cache_name = 'tagadelic_cache_'. $options;
  $cache = cache_get($cache_name);
  
  // make sure cache has data
  if (isset($cache->data)) {
    $tags = $cache->data;
  }
  else {
  
    if (!is_array($vids) || count($vids) == 0) {
      return array();
    }
+	if ( $lang_sel === NULL )
+	{
+		$lang_sel_q = '';
+	}
+	else
+	{
+		$lang_sel_q = ' AND language = "'.$lang_sel.'" ';
+	}
+    $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') '.$lang_sel_q.' GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
-    $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
nchase’s picture

thanks for your contribution. Is this working with the "Localize terms" option? thanks

broon’s picture

Actually, I didn't try that. But I guess it wouldn't work, since localicable terms have no language assigned to them. This is a flaw in my patch, which I noticed because I had some terms which weren't translated because the term is the same in both languages used. So I changed in tagadelic.module following line

$lang_sel_q = ' AND language = "'.$lang_sel.'" ';

to

$lang_sel_q = ' AND (language = "'.$lang_sel.'" OR language = "") ';

Now the not translated terms showed up, too, and now it should also work with localizable terms.

nchase’s picture

thanks for your contribution. Doesn't work with localizable terms...

broon’s picture

Hi snicers,

in cumulus.module, function cumulus_block(), around line 62 it should read:

$tags = tagadelic_get_weighted_tags($vocs, variable_get('cumulus_tagadelic_step', 6), variable_get('cumulus_tagadelic_limit', 24), $clang);
$tags = tagadelic_sort_tags($tags);

These lines fetch the tags via tagadelic (and sort them). Right after that you could try to put the following snippet (which was posted by thread starter) if i18n module is installed:

if (module_exists("i18ntaxonomy")) {
		i18ntaxonomy_localize_terms($tags);
}

For some reason I couldn't get this to work properly, however you could try to use built-in translation service if all terms were translated through the translation interface:

foreach ( $tags AS $tag ) {
  $tag->term = t($tag->term);
}

sin

agrigor1’s picture

Are we going to see a new version with the option of localized terms being shown inside cumulus cloud?

broon’s picture

Well, I'm not the maintainer of this module, neither do I have ever contributed a patch or a module myself. I'm just a php coder and are now working with Drupal for four month. Within that time I already coded several custom modules for clients and tweaked some modules to meet customers needs, but nothing of that was suitable for the community (either to specific or not totally done yet).
Additionally, I don't have knowledge of all helpful modules and how to integrate or utilize them in other modules, so my learning curve is still steep. :)

nchase’s picture

@ sin.star thank you! Your code in #5 is working fine. Thank you!

sinasquax’s picture

If you use this patch (http://drupal.org/node/584376) for tagadelic, you will not need anymore to patch cumulus for language support.

mediameriquat’s picture

Version: 6.x-1.x-dev » 6.x-1.3

I have applied the patch proposed above and cleared all caches to no avail. Cumulus still displays taxonomy items in the default language, without taking in account the current language.

nchase’s picture

there was a second idea... to duplicate the module... one for first language , one for second..

gundara’s picture

check out that one, the taxonomy section http://www.eangkasa.com/content/setting-multilingual-site-drupal-interna...
Cumulus shows a cloud depending on the language picked in the language chooser.

Using the option "Per language terms" for taxonomy does anyway make more sense on a linguistic point of view since different languages use different concepts.

fr4nky’s picture

Version: 6.x-1.3 » 6.x-1.2

function theme_cumulus_weighted($terms) {
+ if (module_exists("i18ntaxonomy")) {
+ i18ntaxonomy_localize_terms($terms);
+ }
$output = '';

This works if you select "localize terms" in the taxonomy vocabulary.

univac’s picture

Hi fr4nky
hi all,
it does not display localized terms in my case.
I am using v6.x-1.4 i.e. the latest available, with Vocabularies configured with "localize terms".
Any ideas?

Thanks for the nice module.

kingqueenyun’s picture

thanks,i know how to do.