function potx_select_form_submit in Translation template extractor 6
Same name and namespace in other branches
- 5.2 potx.module \potx_select_form_submit()
- 5 potx.module \potx_select_form_submit()
- 6.2 potx.module \potx_select_form_submit()
- 7 potx.module \potx_select_form_submit()
Generate translation template or translation file for the requested module.
File
- ./
potx.module, line 93 - Gettext translation template and translation extractor.
Code
function potx_select_form_submit($form, &$form_state) {
// This could take some time.
@set_time_limit(0);
include_once drupal_get_path('module', 'potx') . '/potx.inc';
// Silence status messages.
_potx_status(POTX_STATUS_MESSAGE);
// $form_state['values']['module'] either contains a specific module file name
// with path, or a directory name for a module or a module suite.
// Examples:
// modules/watchdog
// sites/all/modules/potx
// sites/all/modules/i18n/i18n.module
$pathinfo = pathinfo($form_state['values']['module']);
$strip_prefix = 0;
// A specific module file was requested.
if (isset($pathinfo['extension']) && $pathinfo['extension'] == 'module') {
$filename = basename($pathinfo['basename'], '.module');
$files = _potx_explore_dir($pathinfo['dirname'] . '/', $filename);
$strip_prefix = 1 + strlen($pathinfo['dirname']);
$outputname = $filename;
}
else {
$files = _potx_explore_dir($form_state['values']['module'] . '/');
$strip_prefix = 1 + strlen($form_state['values']['module']);
$outputname = $pathinfo['basename'];
}
// Decide on template or translation file generation.
$template_langcode = $translation_langcode = NULL;
if (isset($form_state['values']['langcode']) && $form_state['values']['langcode'] != 'n/a') {
$template_langcode = $form_state['values']['langcode'];
$outputname .= '.' . $template_langcode;
if (!empty($form_state['values']['translations'])) {
$translation_langcode = $template_langcode;
$outputname .= '.po';
}
else {
$outputname .= '.pot';
}
}
else {
$outputname .= '.pot';
}
// Collect every string in affected files. Installer related strings are discared.
foreach ($files as $file) {
_potx_process_file($file, $strip_prefix);
}
// Need to include full parameter list to get to passing the language codes.
_potx_build_files(POTX_STRING_RUNTIME, POTX_BUILD_SINGLE, 'general', '_potx_save_string', '_potx_save_version', '_potx_get_header', $template_langcode, $translation_langcode);
_potx_write_files($outputname, 'attachment');
exit;
}