You are here

function _potx_get_header in Translation template extractor 6.2

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

Returns a header generated for a given file

Parameters

$file: Name of POT file to generate header for

$template_export_langcode: Language code if the template should have language dependent content (like plural formulas and language name) included.

$api_version: Drupal API version to work with.

1 string reference to '_potx_get_header'
potx_select_form_submit in ./potx.module
Generate translation template or translation file for the requested component.

File

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

Code

function _potx_get_header($file, $template_export_langcode = NULL, $api_version = POTX_API_6) {

  // We only have language to use if we should export with that langcode.
  $language = NULL;
  if (isset($template_export_langcode)) {
    $language = db_fetch_object(db_query($api_version > POTX_API_5 ? "SELECT language, name, plurals, formula FROM {languages} WHERE language = '%s'" : "SELECT locale, name, plurals, formula FROM {locales_meta} WHERE locale = '%s'", $template_export_langcode));
  }
  $output = '# $' . 'Id' . '$' . "\n";
  $output .= "#\n";
  $output .= '# ' . (isset($language) ? $language->name : 'LANGUAGE') . ' translation of Drupal (' . $file . ")\n";
  $output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n";
  $output .= "# --VERSIONS--\n";
  $output .= "#\n";
  $output .= "#, fuzzy\n";
  $output .= "msgid \"\"\n";
  $output .= "msgstr \"\"\n";
  $output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
  $output .= '"POT-Creation-Date: ' . date("Y-m-d H:iO") . "\\n\"\n";
  $output .= '"PO-Revision-Date: ' . (isset($language) ? date("Y-m-d H:iO") : 'YYYY-mm-DD HH:MM+ZZZZ') . "\\n\"\n";
  $output .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
  $output .= "\"Language-Team: " . (isset($language) ? $language->name : 'LANGUAGE') . " <EMAIL@ADDRESS>\\n\"\n";
  $output .= "\"MIME-Version: 1.0\\n\"\n";
  $output .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
  $output .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
  if (isset($language->formula) && isset($language->plurals)) {
    $output .= "\"Plural-Forms: nplurals=" . $language->plurals . "; plural=" . strtr($language->formula, array(
      '$' => '',
    )) . ";\\n\"\n\n";
  }
  else {
    $output .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n\n";
  }
  return $output;
}