Context translation
Context settings

This project is not covered by Drupal’s security advisory policy.

This module handles contexts for locale. It requires the custom-locale core patch, which is bundled (for Drupal 6.20) with this module.

Under /admin/settings/language/contexts the available and default contexts are managed.

"Available contexts" are the contexts available to the system.
"Default contexts" are the default contexts for the site, FILO fallback.

The translation integrates into Drupals core Locale module.

Dependencies

  • Locale

Usage

To use, add to settings.php:

<?php
function custom_locale($string = NULL, $langcode = NULL, $reset = FALSE, $options = array()) {
  if (module_exists('locale_context')) {
    return locale_context($string, $langcode, $reset, $options);
  }
  elseif (function_exists('locale')) {
    return locale($string, $langcode, $reset, $options);
  }
  return $string;
}
?>

Developer

Also the use of hook_locale() is extended with $op = 'contexts'. Modules can now provide contexts for translation and use these

<?php
function mymodule_locale($op = 'groups') {
  switch ($op) {
    case 'contexts':
      return array('mymodule' => 'My Module');
  }
}

...

function mymodule_some_function() {
  $a = t('This is my translation in module context', array(), NULL, array('context' => 'mymodule'));
}
?>

Credits

This module was sponsored by Berlingske Media A/S

Project information

Releases