You are here

function timeago_add_js in Timeago 6.2

Same name and namespace in other branches
  1. 7.2 timeago.module \timeago_add_js()

Overrides the default translation of Timeago dates if necessary.

1 call to timeago_add_js()
timeago_format_date in ./timeago.module
Converts a timestamp into a Timeago date.

File

./timeago.module, line 150
Adds support for the Timeago jQuery library.

Code

function timeago_add_js() {

  // Add the Timeago library, the module's helper JS, and the default Drupal
  // translation of Timeago date terms.
  $path = drupal_get_path('module', 'timeago');
  drupal_add_js($path . '/jquery.timeago.js');
  drupal_add_js($path . '/timeago.js');

  // Some languages (Arabic, Polish, Russian, Ukranian, etc.) have different
  // suffixes depending on the numbers used in the dates, so we may need to
  // have more complex translations than Drupal allows. To support these cases,
  // we allow adding a script that will override the translations. Examples
  // are available at https://gist.github.com/6251.
  $path .= '/jquery.timeago.' . $GLOBALS['language']->language . '.js';
  if (file_exists($path)) {
    drupal_add_js($path);
  }
}