diff --git a/potx.drush.inc b/potx.drush.inc index 589162f..a938503 100644 --- a/potx.drush.inc +++ b/potx.drush.inc @@ -2,16 +2,13 @@ /** * @file - * Translation template extractor module drush integration. + * Translation template extractor module drush integration. */ /** * Implements hook_drush_command(). * - * @see drush_parse_command() for a list of recognized keys. - * - * @return - * An associative array describing our command. + * @see drush_parse_command() */ function potx_drush_command() { $items['potx'] = array( @@ -38,25 +35,16 @@ function potx_drush_command() { } /** - * Implementation of hook_drush_help(). - * - * This function is called whenever a drush user calls - * 'drush help potx'. - * - * @param - * A string with the help section (prepended with 'drush:'). - * - * @return - * A string with the help text for our command. + * Implements hook_drush_help(). */ function potx_drush_help($section) { if ($section == 'drush:potx') { $help = dt('Generates translation templates from the given Drupal source code in the current working directory.'); - $help .= "\n\n". dt('Possible potx modes are:'); - $help .= "\n". dt(' single Single file output mode, every file folded into the single output file (default).'); - $help .= "\n". dt(' multiple Multiple file output mode, .info files folded into module .pot files.'); - $help .= "\n". dt(' core Drupal core output mode, .info files folded into general.pot.'); - $help .= "\n\n". dt('If no files are specified, potx will autodiscover files from the current working directory. You can specify concrete files to look at to limit the scope of the operation.'); + $help .= "\n\n" . dt('Possible potx modes are:'); + $help .= "\n" . dt(' single Single file output mode, every file folded into the single output file (default).'); + $help .= "\n" . dt(' multiple Multiple file output mode, .info files folded into module .pot files.'); + $help .= "\n" . dt(' core Drupal core output mode, .info files folded into general.pot.'); + $help .= "\n\n" . dt('If no files are specified, potx will autodiscover files from the current working directory. You can specify concrete files to look at to limit the scope of the operation.'); return $help; } } @@ -74,7 +62,7 @@ function potx_drush_extract($mode = NULL) { if (!is_null($mode) && in_array($mode, array('core', 'multiple', 'single'))) { // First argument could be any of the mode names. - $build_mode = constant('POTX_BUILD_'. strtoupper($mode)); + $build_mode = constant('POTX_BUILD_' . strtoupper($mode)); } // Silence error message reporting. Messages will be reported by at the end. potx_status('set', POTX_STATUS_SILENT); @@ -129,7 +117,7 @@ function potx_drush_extract($mode = NULL) { // Get errors, if any. $errors = potx_status('get'); // Get saved strings. - $strings = _potx_save_string(NULL, NULL, NULL, 0, POTX_STRING_RUNTIME); + $strings = _potx_save_string(NULL, NULL, NULL, 0, POTX_STRING_RUNTIME); $rows[] = array(count($files), count($strings), count($errors)); drush_print_table($rows, TRUE); diff --git a/potx.inc b/potx.inc index 8cd2401..8821ea6 100644 --- a/potx.inc +++ b/potx.inc @@ -21,15 +21,15 @@ * Use Twig and the Symfony YAML parser, found in the vendor directory. */ set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/vendor'); -spl_autoload_register(function($c){ - @include preg_replace('#\\\|_(?!.*\\\)#','/',$c).'.php'; +spl_autoload_register(function ($c) { + @include preg_replace('#\\\|_(?!.*\\\)#', '/', $c) . '.php'; }); use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Exception\ParseException; /** - * The current Drupal major API verion. + * The current Drupal major API version. * * This should be the only difference between different branches of potx.inc */ @@ -560,7 +560,12 @@ function _potx_build_files($string_mode = POTX_STRING_RUNTIME, $build_mode = POT * Drupal API version to work with. */ function _potx_translation_export($translation_export_langcode, $string, $plural = NULL, $api_version = POTX_API_CURRENT) { - include_once 'includes/locale.inc'; + if ($api_version < POTX_API_8) { + include_once 'includes/locale.inc'; + } + else { + module_load_include('inc', 'potx', 'potx.locale'); + } // Stip out slash escapes. $string = stripcslashes($string); @@ -581,7 +586,12 @@ function _potx_translation_export($translation_export_langcode, $string, $plural // String with plural variants. Fill up source string array first. $plural = stripcslashes($plural); $strings = array(); - $number_of_plurals = db_query('SELECT plurals FROM {'. $language_table ."} WHERE {$language_column} = :langcode", array(':langcode' => $translation_export_langcode))->fetchField(); + if ($api_version >= POTX_API_8) { + $number_of_plurals = 2; + } + else { + $number_of_plurals = db_query('SELECT plurals FROM {'. $language_table ."} WHERE {$language_column} = :langcode", array(':langcode' => $translation_export_langcode))->fetchField(); + } $plural_index = 0; while ($plural_index < $number_of_plurals) { if ($plural_index == 0) { @@ -622,7 +632,7 @@ function _potx_translation_export($translation_export_langcode, $string, $plural } /** - * Returns a header generated for a given file + * Returns a header generated for a given file. * * @param $file * Name of POT file to generate header for @@ -631,12 +641,30 @@ function _potx_translation_export($translation_export_langcode, $string, $plural * (like plural formulas and language name) included. * @param $api_version * Drupal API version to work with. + * + * @return string + * The header for the translation file. */ function _potx_get_header($file, $template_export_langcode = NULL, $api_version = POTX_API_CURRENT) { // We only have language to use if we should export with that langcode. $language = NULL; if (isset($template_export_langcode)) { - $language = db_query($api_version > POTX_API_5 ? "SELECT language, name, plurals, formula FROM {languages} WHERE language = :langcode" : "SELECT locale, name, plurals, formula FROM {locales_meta} WHERE locale = :langcode", array(':langcode' => $template_export_langcode))->fetchObject(); + if ($api_version >= POTX_API_8) { + $languages = \Drupal::languageManager()->getLanguages(); + /** @var \Drupal\locale\PluralFormula $PluralFormula */ + $plural_formula = \Drupal::service('locale.plural.formula'); + $language = (object) array( + 'name' => $languages[$template_export_langcode]->getName(), + 'plurals' => $plural_formula->getNumberOfPlurals($template_export_langcode), + // @todo PluralFormulaInterface->getFormula() returns a plural element + // stack instead of an arithmetic formula. This will be fixed in + // https://www.drupal.org/node/2882617 + 'formula' => '(n!=1)', //$plural_formula->getFormula($template_export_langcode), + ); + } + else { + $language = db_query($api_version > POTX_API_5 ? "SELECT language, name, plurals, formula FROM {languages} WHERE language = :langcode" : "SELECT locale, name, plurals, formula FROM {locales_meta} WHERE locale = :langcode", array(':langcode' => $template_export_langcode))->fetchObject(); + } } $output = '# $'.'Id'.'$'."\n"; diff --git a/potx.local.inc b/potx.local.inc index d642740..a29cd85 100644 --- a/potx.local.inc +++ b/potx.local.inc @@ -1,5 +1,10 @@ '_potx_schema_store_lookup', - 'schema_reverse_lookup' => '_potx_schema_reverse_lookup', - 'load_module_metadata' => '_potx_load_module_metadata', - 'store_module_metadata' => '_potx_store_module_metadata', - 'schema_store' => '_potx_schema_store', - 'schema_load' => '_potx_schema_load', + 'schema_store_lookup' => '_potx_schema_store_lookup', + 'schema_reverse_lookup' => '_potx_schema_reverse_lookup', + 'load_module_metadata' => '_potx_load_module_metadata', + 'store_module_metadata' => '_potx_store_module_metadata', + 'schema_store' => '_potx_schema_store', + 'schema_load' => '_potx_schema_load', ); if ($module_path !== NULL) { @@ -48,10 +53,12 @@ function _potx_find_all_modules($module_path) { $module_path = $module_path . '/'; } - // The list of directories to check in the path, to find out if we are in a Drupal install directory. + // The list of directories to check in the path, to find out if we are in a + // Drupal install directory. $checks = array('/sites/', '/core/', '/profiles/', '/modules/', '/themes/'); - // The list of paths that could contain "modules/" or "themes/" subdirectories. + // The list of paths that could contain "modules/" or "themes/" + // subdirectories. $search_paths = array(); foreach ($checks as $check) { @@ -62,7 +69,7 @@ function _potx_find_all_modules($module_path) { $root = $parts[0]; // The Drupal core directory contains a config/schema subdirectory, which - // is not part of any module or theme. + // is not part of any module or theme. $_potx_found_modules['core']['path'] = $root . '/core'; $search_paths[] = $root; @@ -95,7 +102,7 @@ function _potx_find_all_modules($module_path) { * Recursively find all modules in a given path, by looking for .info.yml files. * * @param string $path - * The search path + * The search path. */ function _potx_find_modules($path) { global $_potx_found_modules; @@ -124,11 +131,10 @@ function _potx_find_modules($path) { * * @param array $keys * List of config matching keys in a config schema file. - * * @param string $module_name * Name of the module containing the schema. */ -function _potx_schema_store_lookup($keys, $module_name) { +function _potx_schema_store_lookup(array $keys, $module_name) { global $_potx_schema_lookup; $_potx_schema_lookup = array_merge($_potx_schema_lookup, array_fill_keys($keys, $module_name)); } @@ -146,7 +152,7 @@ function _potx_schema_store_lookup($keys, $module_name) { * * @see _potx_find_matching_schema() */ -function _potx_schema_reverse_lookup($matching_candidates) { +function _potx_schema_reverse_lookup(array $matching_candidates) { global $_potx_schema_lookup; global $_potx_reverse_lookup_built; @@ -193,10 +199,11 @@ function _potx_build_reverse_lookup() { $keys = array_keys($yaml); $potx_callbacks['schema_store_lookup']($keys, $module_name); - } catch (ParseException $e) { + } + catch (ParseException $e) { watchdog('potx', "YAML parseing error on file @path: @error", array( - '@path' => $file_path, - '@error' => $e->getMessage(), + '@path' => $file_path, + '@error' => $e->getMessage(), )); } } @@ -237,10 +244,11 @@ function _potx_load_module_metadata($module_name) { try { $info_yaml = Yaml::parse($code); $_potx_module_metadata[$module_name]['dependencies'] = isset($info_yaml['dependencies']) ? $info_yaml['dependencies'] : array(); - } catch (ParseException $e) { + } + catch (ParseException $e) { watchdog('potx', "YAML parseing error on file @path: @error", array( - '@path' => $file_path, - '@error' => $e->getMessage(), + '@path' => $file_path, + '@error' => $e->getMessage(), )); return FALSE; @@ -264,11 +272,11 @@ function _potx_load_module_metadata($module_name) { * Not used locally by potx. * * @param string $module_name - * The module's name + * The module's name. * @param array $metadata - * The module's metadata + * The module's metadata. */ -function _potx_store_module_metadata($module_name, $metadata) { +function _potx_store_module_metadata($module_name, array $metadata) { // Intentionally Left Empty. } @@ -294,6 +302,9 @@ function _potx_schema_store($module_name) { * * @param string $module_name * The module's name. + * + * @return array|null + * The module's processed schema or NULL. */ function _potx_schema_load($module_name) { global $_potx_schema_cache; diff --git a/potx.locale.inc b/potx.locale.inc new file mode 100644 index 0000000..aee0305 --- /dev/null +++ b/potx.locale.inc @@ -0,0 +1,70 @@ + 1) { + return "\"\"\n\"" . implode("\"\n\"", $parts) . "\"\n"; + } + // Single line string. + elseif (count($parts) == 1) { + return "\"$parts[0]\"\n"; + } + // No translation. + else { + return "\"\"\n"; + } +} + +/** + * Custom word wrapping for Portable Object (Template) files. + */ +function _locale_export_wrap($str, $len) { + $words = explode(' ', $str); + $return = array(); + + $cur = ""; + $nstr = 1; + while (count($words)) { + $word = array_shift($words); + if ($nstr) { + $cur = $word; + $nstr = 0; + } + elseif (strlen("$cur $word") > $len) { + $return[] = $cur . " "; + $cur = $word; + } + else { + $cur = "$cur $word"; + } + } + $return[] = $cur; + + return implode("\n", $return); +} diff --git a/potx.module b/potx.module index 524f96b..fd8464f 100644 --- a/potx.module +++ b/potx.module @@ -2,28 +2,31 @@ /** * @file - * Drupal translation template extractor. + * Drupal translation template extractor. * - * This module helps people extract translatable strings from Drupal source - * code. The user interface allows translators to choose which part of the - * current Drupal instance to translate. The module also provides an API for - * other modules (such as coder and l10n_server) to use. + * This module helps people extract translatable strings from Drupal source + * code. The user interface allows translators to choose which part of the + * current Drupal instance to translate. The module also provides an API for + * other modules (such as coder and l10n_server) to use. */ +use Drupal\Core\Routing\RouteMatchInterface; + /** - * Implementation of hook_help(). + * Implements hook_help(). */ -function potx_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) { +function potx_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'potx.extract_translation': - return '
'. t('This page allows you to generate translation templates for module and theme files. Select the module or theme you wish to generate a template file for. A single Gettext Portable Object (Template) file is generated, so you can easily save it and start translation.') .'
'; + return '' . t('This page allows you to generate translation templates for module and theme files. Select the module or theme you wish to generate a template file for. A single Gettext Portable Object (Template) file is generated, so you can easily save it and start translation.') . '
'; } } /** - * Implementation of hook_reviews(). Coder module integration. + * Implements hook_reviews(). * - * Provides the list of reviews provided by this module. + * Provides Coder module integration. Returns a list of reviews provided by this + * module. */ function potx_reviews() { $review = array( @@ -34,7 +37,7 @@ function potx_reviews() { '#type' => 'callback', '#value' => 'potx_coder_review', ), - ) + ), ); return array('potx' => $review); } diff --git a/src/Form/PotxExtractTranslationForm.php b/src/Form/PotxExtractTranslationForm.php index 36a2047..8c686f5 100644 --- a/src/Form/PotxExtractTranslationForm.php +++ b/src/Form/PotxExtractTranslationForm.php @@ -9,6 +9,11 @@ use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +/** + * Class PotxExtractTranslationForm. + * + * @package Drupal\potx\Form + */ class PotxExtractTranslationForm extends FormBase { /** @@ -37,6 +42,10 @@ class PotxExtractTranslationForm extends FormBase { * * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager service. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler + * The theme handler. */ public function __construct(LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) { $this->languageManager = $language_manager; @@ -80,7 +89,7 @@ class PotxExtractTranslationForm extends FormBase { continue; } - $options[$langcode] = $this->t('Template file for @langname translations', array('@langname' => $this->t($language->getName()))); + $options[$langcode] = $this->t('Template file for @langname translations', array('@langname' => $language->getName())); } $form['langcode'] = array( '#type' => 'radios', @@ -92,12 +101,14 @@ class PotxExtractTranslationForm extends FormBase { $form['translations'] = array( '#type' => 'checkbox', '#title' => $this->t('Include translations'), - '#description' => $this->t('Include translations of strings in the file generated. Not applicable for language independent templates.') + '#description' => $this->t('Include translations of strings in the file generated. Not applicable for language independent templates.'), ); } - $form['submit'] = array( + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( '#type' => 'submit', + '#button_type' => 'primary', '#value' => $this->t('Extract'), ); @@ -133,29 +144,29 @@ class PotxExtractTranslationForm extends FormBase { // $form_state->getValue('component') either contains a specific file name // with path, or a directory name for a module/theme or a module suite. // Examples: - // modules/watchdog - // sites/all/modules/coder - // sites/all/modules/i18n/i18n.module - // themes/garland - + // - modules/watchdog + // - sites/all/modules/coder + // - sites/all/modules/i18n/i18n.module + // - themes/garland. $component = $form_state->getValue('component'); $pathinfo = pathinfo($component); if (!isset($pathinfo['filename'])) { - // The filename key is only available in PHP 5.2.0+ + // The filename key is only available in PHP 5.2.0+. $pathinfo['filename'] = substr($pathinfo['basename'], 0, strrpos($pathinfo['basename'], '.')); } if (isset($pathinfo['extension'])) { - // A specific module or theme file was requested (otherwise there should be no extension). + // A specific module or theme file was requested (otherwise there should + // be no extension). potx_local_init($pathinfo['dirname']); - $files = _potx_explore_dir($pathinfo['dirname'] .'/', $pathinfo['filename']); + $files = _potx_explore_dir($pathinfo['dirname'] . '/', $pathinfo['filename']); $strip_prefix = 1 + strlen($pathinfo['dirname']); $outputname = $pathinfo['filename']; } // A directory name was requested. else { potx_local_init($component); - $files = _potx_explore_dir($component .'/'); + $files = _potx_explore_dir($component . '/'); $strip_prefix = 1 + strlen($component); $outputname = $pathinfo['basename']; } @@ -164,7 +175,7 @@ class PotxExtractTranslationForm extends FormBase { $template_langcode = $translation_langcode = NULL; if ($form_state->hasValue('langcode') && ($form_state->getValue('langcode') != 'n/a')) { $template_langcode = $form_state->getValue('langcode'); - $outputname .= '.'. $template_langcode; + $outputname .= '.' . $template_langcode; if (!empty($form_state->getValue('translations'))) { $translation_langcode = $template_langcode; $outputname .= '.po'; @@ -177,7 +188,8 @@ class PotxExtractTranslationForm extends FormBase { $outputname .= '.pot'; } - // Collect every string in affected files. Installer related strings are discared. + // Collect every string in affected files. Installer related strings are + // discarded. foreach ($files as $file) { _potx_process_file($file, $strip_prefix); } @@ -195,7 +207,7 @@ class PotxExtractTranslationForm extends FormBase { * Generate a hierarchical structured list of components. * * @return array - * Array in the directory structure identified. + * Array in the directory structure identified. * - 'normal' keyed elements being subfolders * - '#name' elements being component objects for the 'name' component * - '#-count' being the file count of all components in the directory @@ -207,6 +219,7 @@ class PotxExtractTranslationForm extends FormBase { // Get a list of all enabled modules and themes. $modules = $this->moduleHandler->getModuleList(); $themes = $this->themeHandler->listInfo(); + /** @var \Drupal\Core\Extension\Extension[] $result */ $result = array_merge($modules, $themes); foreach ($result as $component) { // Build directory tree structure. @@ -230,14 +243,18 @@ class PotxExtractTranslationForm extends FormBase { /** * Build a chunk of the component selection form. * - * @param $form + * @param array $form * Form to populate with fields. - * @param $components - * Structured array with components as returned by $this->generateComponentList(). - * @param $dirname + * @param array $components + * Structured array with components as returned by + * $this->generateComponentList(). + * @param string $dirname * Name of directory handled. + * + * @return mixed + * A count of the number of components or void. */ - function buildComponentSelector(&$form, &$components, $dirname = '') { + private function buildComponentSelector(array &$form, array &$components, $dirname = '') { // Pop off count of components in this directory. if (isset($components['#-count'])) { @@ -245,14 +262,13 @@ class PotxExtractTranslationForm extends FormBase { unset($components['#-count']); } - //ksort($components); $dirkeys = array_keys($components); // A directory with one component. if (isset($component_count) && (count($components) == 1)) { $component = array_shift($components); $dirname = $component->getPath(); - $form[$this->getFormElementID('dir', $dirname)] = array( + $form[$this->getFormElementId('dir', $dirname)] = array( '#type' => 'radio', '#title' => t('Extract from %name in the %directory directory', array('%directory' => $dirname, '%name' => $component->getName())), '#description' => t('Generates output from all files found in this directory.'), @@ -268,7 +284,7 @@ class PotxExtractTranslationForm extends FormBase { if (preg_match('!/(modules|themes)\\b(/.+)?!', $dirname, $pathmatch)) { $t_args = array('@directory' => substr($dirname, 1)); if (isset($pathmatch[2])) { - $form[$this->getFormElementID('dir', $dirname)] = array( + $form[$this->getFormElementId('dir', $dirname)] = array( '#type' => 'radio', '#title' => t('Extract from all in directory "@directory"', $t_args), '#description' => t('To extract from a single component in this directory, choose the desired entry in the fieldset below.'), @@ -284,7 +300,7 @@ class PotxExtractTranslationForm extends FormBase { '#collapsible' => TRUE, '#collapsed' => TRUE, ); - $form[$this->getFormElementID('fs', $dirname)] =& $element; + $form[$this->getFormElementId('fs', $dirname)] =& $element; } else { $element =& $form; @@ -297,9 +313,9 @@ class PotxExtractTranslationForm extends FormBase { $t_args = array( '%directory' => $components[$entry]->getPath(), '%name' => $components[$entry]->getName(), - '%pattern' => $components[$entry]->getName() .'.*', + '%pattern' => $components[$entry]->getName() . '.*', ); - $element[$this->getFormElementID('com', $components[$entry]->getExtensionFilename())] = array( + $element[$this->getFormElementId('com', $components[$entry]->getExtensionFilename())] = array( '#type' => 'radio', '#title' => $this->t('Extract from %name', $t_args), '#description' => $this->t('Extract from files named %pattern in the %directory directory.', $t_args), @@ -321,14 +337,17 @@ class PotxExtractTranslationForm extends FormBase { /** * Generate a sane form element ID for the current radio button. * - * @param $type - * Type of ID generated: 'fs' for fieldset, 'dir' for directory, 'com' for component. - * @param $path + * @param string $type + * Type of ID generated: 'fs' for fieldset, 'dir' for directory, 'com' for + * component. + * @param string $path * Path of file we generate an ID for. + * * @return string * The generated ID. */ - function getFormElementID($type, $path) { - return 'potx-'. $type .'-'. preg_replace('/[^a-zA-Z0-9]+/', '-', $path); + private function getFormElementId($type, $path) { + return 'potx-' . $type . '-' . preg_replace('/[^a-zA-Z0-9]+/', '-', $path); } + } diff --git a/tests/potx.test b/tests/potx.test index 3119bc0..a4abd35 100644 --- a/tests/potx.test +++ b/tests/potx.test @@ -9,16 +9,18 @@ use Drupal\simpletest\WebTestBase; * * @group potx */ - class PotxTest extends WebTestBase { public static $modules = array('locale', 'potx'); + /** + * {@inheritdoc} + */ public function setUp() { // Add potx.inc which we test for its functionality. - include_once(__DIR__ . '/../../potx.inc'); - include_once(__DIR__ . '/../../potx.local.inc'); + include_once __DIR__ . '/../../potx.inc'; + include_once __DIR__ . '/../../potx.local.inc'; potx_local_init(); // Store empty error message for reuse in multiple cases. $this->empty_error = t('Empty string attempted to be localized. Please do not leave test code for localization in your source.'); @@ -74,7 +76,7 @@ class PotxTest extends WebTestBase { $this->assert($this->potx_status[0][0] == $this->empty_error, 'First empty error found.'); $this->assert($this->potx_status[1][0] == $this->empty_error, 'Second empty error found.'); $this->assert($this->potx_status[2][0] == t('In @function(), the singular and plural strings should be literal strings. There should be no variables, concatenation, constants or even a t() call there.', array( - '@function' => 'format_plural' + '@function' => 'format_plural', )), 'Fourth error found.'); $this->assert($this->potx_status[3][0] == $this->empty_error, 'Third empty error found.'); } @@ -209,6 +211,7 @@ function potx_test_7_with_syntax_error() { $this->assertMsgID('PHP Syntax error gracefully handled'); } + public function testDrupal8LanguageManager() { $filename = 'LanguageManager.php'; $file_content = " @@ -472,7 +475,6 @@ class PotxMockLanguageManager { } // Test extraction of config schema labels. - // Make sure all the 'label' strings are extracted. $this->assertMsgID('Test integer'); $this->assertMsgID('Test string with "quotes"'); @@ -484,7 +486,6 @@ class PotxMockLanguageManager { $this->assertNoMsgID('sequence'); // Test extraction of shipped config translatables. - $this->assertMsgID('A string with "translatable: true" property'); $this->assertMsgIDContext('Y-m-d', 'PHP date format'); $this->assertMsgIDContext('Test string with context', 'Test context'); @@ -634,8 +635,7 @@ class TestConstraint { /** * Build the output from parsed files. */ - private function buildOutput($api_version, $string_mode = POTX_STRING_RUNTIME) - { + private function buildOutput($api_version, $string_mode = POTX_STRING_RUNTIME) { potx_status('set', POTX_STATUS_STRUCTURED); _potx_build_files($string_mode, POTX_BUILD_SINGLE, 'general', '_potx_save_string', '_potx_save_version', '_potx_get_header', NULL, NULL, $api_version); @@ -720,14 +720,14 @@ class TestConstraint { * Debug functionality until simpletest built-in debugging is backported. */ private function outputScreenContents($description = 'output', $basename = 'output') { - // This is a hack to get a directory that won't be cleaned up by simpletest - $file_dir = file_directory_path() .'/../simpletest_output_pages'; + // This is a hack to get a directory that won't be cleaned up by simpletest. + $file_dir = file_directory_path() . '/../simpletest_output_pages'; if (!is_dir($file_dir)) { mkdir($file_dir, 0777, TRUE); } - $output_path = "$file_dir/$basename.". $this->randomName(10) .'.html'; + $output_path = "$file_dir/$basename." . $this->randomName(10) . '.html'; $rv = file_put_contents($output_path, $this->drupalGetContent()); - $this->pass("$description: ". l('Contents of result page', $output_path)); + $this->pass("$description: " . l('Contents of result page', $output_path)); } }