Hi, I've a Drupal website with i18n enabled. Currently the language channel item is manually set so you have to create different views display. So I've created a simple patch to use the current language on the language channel item.

If the language field configuration is leaved empty and if i18n module is enabled the preprocess function will set the item to the current language.

  • This is the item definition with the preprocess function:
  $elements['language'] = array(
    'preprocess functions' => array('views_rss_core_preprocess_channel_language'),
    'description' => t('The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. See list of <a href="@w3c_url">allowable values</a> for this element defined by the W3C. If you have i18n content module enabled you can leave this field empty. It will be filled with the current language.', array(
      '@w3c_url' => url('http://www.w3.org/TR/REC-html40/struct/dirlang.html', array('fragment' => 'langcodes')),
    'help' => 'http://www.rssboard.org/rss-profile#element-channel-language',
  • This is the preprocess function views_rss_core_preprocess_channel_language():
 * Preprocess function for channel <language> element.
function views_rss_core_preprocess_channel_language(&$variables) {
  if (module_exists('i18n')){
    global $language;
    if (empty($variables['elements'][0]['value'])) {
      $variables['elements'][0]['value'] = $language->language;

What do you think about?

views_rss-i18nlanguagechannel.patch2.06 KBFiNeX
Members fund testing for the Drupal project. Drupal Association Learn more


maciej.zgadzaj’s picture

Status: Active » Needs work

Very good idea, although to be honest I don't see any reason why we should limit this feature for sites with i18n module only. $language is always defined, whether you have locale module enabled or not, so I think the test for i18n being enabled could be dropped completely (and description modified accordingly).

maciej.zgadzaj’s picture

Status: Needs work » Fixed
FiNeX’s picture

@maciej: I agree, thanks :-)

Status: Fixed » Closed (fixed)

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