You are here

function _potx_add_date_strings in Translation template extractor 8

Same name and namespace in other branches
  1. 5.2 potx.inc \_potx_add_date_strings()
  2. 5 potx.inc \_potx_add_date_strings()
  3. 6.3 potx.inc \_potx_add_date_strings()
  4. 6 potx.inc \_potx_add_date_strings()
  5. 6.2 potx.inc \_potx_add_date_strings()
  6. 7.3 potx.inc \_potx_add_date_strings()
  7. 7 potx.inc \_potx_add_date_strings()
  8. 7.2 potx.inc \_potx_add_date_strings()

Add date strings, which cannot be extracted otherwise.

This is called for locale.module.

Parameters

string $file: Name of the file parsed.

string $save_callback: Callback function used to save strings.

int $api_version: Drupal API version to work with.

1 call to _potx_add_date_strings()
_potx_parse_php_file in ./potx.inc
Parse a PHP file for translatables.

File

./potx.inc, line 1709
Extraction API used by the web and command line interface.

Code

function _potx_add_date_strings($file, $save_callback, $api_version = POTX_API_CURRENT) {
  for ($i = 1; $i <= 12; $i++) {
    $stamp = mktime(0, 0, 0, $i, 1, 1971);
    if ($api_version > POTX_API_6) {

      // From Drupal 7, long month names are saved with this context.
      $save_callback(date("F", $stamp), 'Long month name', $file);
    }
    elseif ($api_version > POTX_API_5) {

      // Drupal 6 uses a little hack. No context.
      $save_callback('!long-month-name ' . date("F", $stamp), POTX_CONTEXT_NONE, $file);
    }
    else {

      // Older versions just accept the confusion, no context.
      $save_callback(date("F", $stamp), POTX_CONTEXT_NONE, $file);
    }

    // Short month names lack a context anyway.
    $save_callback(date("M", $stamp), POTX_CONTEXT_NONE, $file);
  }
  for ($i = 0; $i <= 7; $i++) {
    $stamp = $i * 86400;
    $save_callback(date("D", $stamp), POTX_CONTEXT_NONE, $file);
    $save_callback(date("l", $stamp), POTX_CONTEXT_NONE, $file);
  }
  $save_callback('am', POTX_CONTEXT_NONE, $file);
  $save_callback('pm', POTX_CONTEXT_NONE, $file);
  $save_callback('AM', POTX_CONTEXT_NONE, $file);
  $save_callback('PM', POTX_CONTEXT_NONE, $file);
}