Commit 12c2fbbe authored by alexpott's avatar alexpott

Issue #1533250 by YesCT, fran seva, TravisCarden, xjm, sriharsha.uppuluri |...

Issue #1533250 by YesCT, fran seva, TravisCarden, xjm, sriharsha.uppuluri | NROTC_Webmaster: Many coding standards clean-ups in locale module.
parent 01bb1268
......@@ -45,7 +45,8 @@
* Multiple custom modules or themes sharing the same po file should have
* matching definitions. Such as modules and sub-modules or multiple modules in
* the same project/code tree. Both "interface translation project" and
* "interface translation server pattern" definitions of these modules should match.
* "interface translation server pattern" definitions of these modules should
* match.
*
* Example .info.yml file properties for a custom module with a po file located
* on a remote translation server.
......@@ -109,7 +110,7 @@
* @param array $projects
* Project data as returned by update_get_projects().
*
* @see locale_translation_project_list().
* @see locale_translation_project_list()
* @ingroup interface_translation_properties
*/
function hook_locale_translation_projects_alter(&$projects) {
......
......@@ -2,7 +2,7 @@
/**
* @file
* Batch process to check the availability of remote or local po files.
* Batch process to check the availability of remote or local po files.
*/
use GuzzleHttp\Exception\RequestException;
......@@ -85,7 +85,7 @@ function locale_translation_batch_status_check($project, $langcode, $options = a
/**
* Batch finished callback: Set result message.
*
* @param boolean $success
* @param bool $success
* TRUE if batch successfully completed.
* @param array $results
* Batch results.
......@@ -93,13 +93,13 @@ function locale_translation_batch_status_check($project, $langcode, $options = a
function locale_translation_batch_status_finished($success, $results) {
if ($success) {
if (isset($results['failed_files'])) {
if (\Drupal::moduleHandler()->moduleExists('dblog')) {
$message = format_plural(count($results['failed_files']), 'One translation file could not be checked. <a href="@url">See the log</a> for details.', '@count translation files could not be checked. <a href="@url">See the log</a> for details.', array('@url' => url('admin/reports/dblog')));
}
else {
$message = format_plural(count($results['failed_files']), 'One translation files could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.');
}
drupal_set_message($message, 'error');
if (\Drupal::moduleHandler()->moduleExists('dblog')) {
$message = format_plural(count($results['failed_files']), 'One translation file could not be checked. <a href="@url">See the log</a> for details.', '@count translation files could not be checked. <a href="@url">See the log</a> for details.', array('@url' => url('admin/reports/dblog')));
}
else {
$message = format_plural(count($results['failed_files']), 'One translation files could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.');
}
drupal_set_message($message, 'error');
}
if (isset($results['files'])) {
drupal_set_message(format_plural(
......@@ -201,9 +201,9 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
/**
* Batch finished callback: Set result message.
*
* @param boolean $success
* @param bool $success
* TRUE if batch successfully completed.
* @param array
* @param array $results
* Batch results.
*/
function locale_translation_batch_fetch_finished($success, $results) {
......@@ -220,7 +220,7 @@ function locale_translation_batch_fetch_finished($success, $results) {
* @param string $uri
* URI of remote file.
*
* @return array|boolean
* @return array|bool
* Associative array of file data with the following elements:
* - last_modified: Last modified timestamp of the translation file.
* - (optional) location: The location of the translation file. Is only set
......
......@@ -24,7 +24,6 @@
* LOCALE_NOT_CUSTOMIZED.
* - 'finish_feedback': Whether or not to give feedback to the user when the
* batch is finished. Optional, defaults to TRUE.
*
* @param $force
* (optional) Import all available files, even if they were imported before.
*
......@@ -75,8 +74,8 @@ function locale_translate_batch_import_files($options, $force = FALSE) {
* Project names from which to get the translation files and history.
* Defaults to all projects.
* @param array $langcodes
* Language codes from which to get the translation files and history.
* Defaults to all languagues
* Language codes from which to get the translation files and history.
* Defaults to all languages.
*
* @return array
* An array of interface translation files keyed by their URI.
......@@ -112,7 +111,6 @@ function locale_translate_get_interface_translation_files($projects = array(), $
*
* @param $files
* Array of file objects to import.
*
* @param array $options
* An array with options that can have the following elements:
* - 'langcode': The language code. Optional, defaults to NULL, which means
......@@ -142,7 +140,7 @@ function locale_translate_batch_build($files, $options) {
$operations[] = array('locale_translate_batch_import', array($file, $options));
}
// Save the translation status of all files.
$operations[] = array('locale_translate_batch_import_save', array());
$operations[] = array('locale_translate_batch_import_save', array());
// Add a final step to refresh JavaScript and configuration strings.
$operations[] = array('locale_translate_batch_refresh', array());
......@@ -167,10 +165,9 @@ function locale_translate_batch_build($files, $options) {
*
* @param object $file
* A file object of the gettext file to be imported. The file object must
* contain a language parameter
* (other than LanguageInterface::LANGCODE_NOT_SPECIFIED). This is used as
* the language of the import.
*
* contain a language parameter (other than
* LanguageInterface::LANGCODE_NOT_SPECIFIED). This is used as the language of
* the import.
* @param array $options
* An array with options that can have the following elements:
* - 'langcode': The language code.
......@@ -182,7 +179,6 @@ function locale_translate_batch_build($files, $options) {
* LOCALE_NOT_CUSTOMIZED.
* - 'message': Alternative message to display during import. Note, this must
* be sanitized text.
*
* @param $context
* Contains a list of files imported.
*/
......@@ -474,9 +470,9 @@ function locale_translate_file_attach_properties($file, $options = array()) {
* Defaults to all projects.
* @param array $langcodes
* Language codes from which to delete the translation files and history.
* Defaults to all languagues
* Defaults to all languages.
*
* @return boolean
* @return bool
* TRUE if files are removed successfully. FALSE if one or more files could
* not be deleted.
*/
......@@ -543,10 +539,10 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar
foreach ($names as $name) {
$batch_names[] = $name;
$i++;
// During installation the caching of configuration objects is disabled
// so it is very expensive to initialize the \Drupal::config() object on each request.
// We batch a small number of configuration object upgrades together to
// improve the overall performance of the process.
// During installation the caching of configuration objects is disabled so
// it is very expensive to initialize the \Drupal::config() object on each
// request. We batch a small number of configuration object upgrades
// together to improve the overall performance of the process.
if ($i % 20 == 0) {
$operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes));
$batch_names = array();
......@@ -571,7 +567,7 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar
/**
* Performs configuration translation refresh as a batch step.
*
* @param string $name
* @param string $names
* Name of configuration object to update.
* @param array $langcodes
* (optional) Array of language codes to update. Defaults to all languages.
......@@ -595,12 +591,12 @@ function locale_config_batch_refresh_name(array $names, array $langcodes, array
/**
* Finishes callback of system page locale import batch.
*
* @see locale_config_batch_build()
*
* @param bool $success
* Information about the success of the batch import.
* @param array $results
* Information about the results of the batch import.
*
* @see locale_config_batch_build()
*/
function locale_config_batch_finished($success, array $results) {
if ($success) {
......
......@@ -114,8 +114,8 @@ function locale_translation_build_projects() {
))
->execute();
// Invalidate the cache of translatable projects.
locale_translation_clear_cache_projects();
// Invalidate the cache of translatable projects.
locale_translation_clear_cache_projects();
}
return $projects;
}
......@@ -193,7 +193,8 @@ function _locale_translation_prepare_project_list($data, $type) {
function locale_translation_default_translation_server() {
$pattern = \Drupal::config('locale.settings')->get('translation.default_server_pattern');
// An additional check is required here. During the upgrade process
// \Drupal::config()->get() returns NULL. We use the defined value as fallback.
// \Drupal::config()->get() returns NULL. We use the defined value as
// fallback.
$pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
return array(
......@@ -211,8 +212,9 @@ function locale_translation_default_translation_server() {
*
* @return array
* Available sources indexed by project and language.
*
* @todo Return batch or NULL.
*/
// @todo Return batch or NULL
function locale_translation_check_projects($projects = array(), $langcodes = array()) {
if (locale_translation_use_remote_source()) {
// Retrieve the status of both remote and local translation sources by
......
......@@ -123,7 +123,7 @@ function locale_schema() {
),
),
'indexes' => array(
'lid' => array('lid'),
'lid' => array('lid'),
),
);
......@@ -170,8 +170,8 @@ function locale_schema() {
),
),
'indexes' => array(
'string_id' => array('sid'),
'string_type' => array('sid', 'type'),
'string_id' => array('sid'),
'string_type' => array('sid', 'type'),
),
);
......
......@@ -155,13 +155,14 @@ function locale_help($route_name, RouteMatchInterface $route_match) {
return $output;
case 'language.admin_overview':
return '<p>' . t('Interface translations are automatically imported when a language is added, or when new modules or themes are enabled. The report <a href="!update">Available translation updates</a> shows the status. Interface text can be customized in the <a href="!translate">user interface translation</a> page.', array('!update' => \Drupal::url('locale.translate_status'), '!translate' => \Drupal::url('locale.translate_page'))) . '</p>';
return '<p>' . t('Interface translations are automatically imported when a language is added, or when new modules or themes are enabled. The report <a href="!update">Available translation updates</a> shows the status. Interface text can be customized in the <a href="!translate">user interface translation</a> page.', array('!update' => \Drupal::url('locale.translate_status'), '!translate' => \Drupal::url('locale.translate_page'))) . '</p>';
case 'locale.translate_page':
$output = '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: Because translation tasks involve many strings, it may be more convenient to <a title="User interface translation export" href="!export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings in a specific language.', array('!export' => \Drupal::url('locale.translate_export'))) . '</p>';
return $output;
case 'locale.translate_import':
$output = '<p>' . t('Translation files are automatically downloaded and imported when <a title="Languages" href="!language">languages</a> are added, or when modules or themes are enabled.', array('!language' => \Drupal::url('language.admin_overview'))). '</p>';
$output = '<p>' . t('Translation files are automatically downloaded and imported when <a title="Languages" href="!language">languages</a> are added, or when modules or themes are enabled.', array('!language' => \Drupal::url('language.admin_overview'))) . '</p>';
$output .= '<p>' . t('This page allows translators to manually import translated strings contained in a Gettext Portable Object (.po) file. Manual import may be used for customized translations or for the translation of custom modules and themes. To customize translations you can download a translation file from the <a href="!url">Drupal translation server</a> or <a title="User interface translation export" href="!export">export</a> translations from the site, customize the translations using a Gettext translation editor, and import the result using this page.', array('!url' => 'https://localize.drupal.org', '!export' => \Drupal::url('locale.translate_export'))) . '</p>';
$output .= '<p>' . t('Note that importing large .po files may take several minutes.') . '</p>';
return $output;
......@@ -290,6 +291,7 @@ function locale_translatable_language_list() {
* @param $langcode
* Optional language code to translate to a language other than
* what is used to display the page.
*
* @return
* The numeric index of the plural variant to use for this $langcode and
* $count combination or -1 if the language was not found or does not have a
......@@ -412,7 +414,7 @@ function locale_queue_info() {
* queue data.
*
* @param array $data
* Queue data array containing:
* Queue data array containing:
* - Function name.
* - Array of function arguments. Optionally contains the batch context data.
*
......@@ -481,7 +483,8 @@ function locale_system_update(array $components) {
$projects = array_keys(locale_translation_build_projects());
if ($list = array_intersect($list, $projects)) {
module_load_include('fetch.inc', 'locale');
// Get translation status of the projects, download and update translations.
// Get translation status of the projects, download and update
// translations.
$options = _locale_translation_default_update_options();
$batch = locale_translation_batch_update_build($list, array(), $options);
batch_set($batch);
......@@ -514,7 +517,8 @@ function locale_system_remove($components) {
\Drupal\locale\Locale::config()->deleteComponentTranslations($components, array_keys($language_list));
// Only when projects are removed, the translation files and records will be
// deleted. Not each disabled module will remove a project. E.g. sub modules.
// deleted. Not each disabled module will remove a project, e.g., sub
// modules.
$projects = array_keys(locale_translation_get_projects());
if ($list = array_intersect($list, $projects)) {
locale_translation_file_history_delete($list);
......@@ -561,6 +565,7 @@ function locale_js_alter(&$javascript) {
*
* @param array $files
* An array of local file paths.
*
* @return string|null
* The filepath to the translation file or NULL if no translation is
* applicable.
......@@ -693,7 +698,7 @@ function locale_form_language_admin_overview_form_alter(&$form, &$form_state) {
}
/**
* Implements hook_form_FORM_ID_alter() for language_admin_add_form(().
* Implements hook_form_FORM_ID_alter() for language_admin_add_form().
*/
function locale_form_language_admin_add_form_alter(&$form, &$form_state) {
$form['predefined_submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit';
......@@ -847,7 +852,7 @@ function locale_translation_get_file_history() {
* @param object $file
* Object representing the file just imported.
*
* @return integer
* @return int
* FALSE on failure. Otherwise SAVED_NEW or SAVED_UPDATED.
*/
function locale_translation_update_file_history($file) {
......@@ -874,7 +879,7 @@ function locale_translation_update_file_history($file) {
* @param array $projects
* Project name(s) to be deleted from the file history. If both project(s) and
* language code(s) are specified the conditions will be ANDed.
* @param array $langcode
* @param array $langcodes
* Language code(s) to be deleted from the file history.
*/
function locale_translation_file_history_delete($projects = array(), $langcodes = array()) {
......@@ -963,6 +968,7 @@ function locale_translation_status_save($project, $langcode, $type, $data) {
}
}
break;
case LOCALE_TRANSLATION_CURRENT:
$data->last_checked = REQUEST_TIME;
$status[$project][$langcode]->timestamp = $data->timestamp;
......@@ -1200,7 +1206,8 @@ function _locale_parse_js_file($filepath) {
$source = \Drupal::service('locale.storage')->findString($match);
if (!$source) {
// We don't have the source string yet, thus we insert it into the database.
// We don't have the source string yet, thus we insert it into the
// database.
$source = \Drupal::service('locale.storage')->createString($match);
}
......@@ -1267,7 +1274,7 @@ function _locale_rebuild_js($langcode = NULL) {
// Only add strings with a translation to the translations array.
$conditions = array(
'type' => 'javascript',
'language' => $language->id,
'language' => $language->id,
'translated' => TRUE,
);
$translations = array();
......@@ -1296,7 +1303,8 @@ function _locale_rebuild_js($langcode = NULL) {
// There is (on purpose) no front end to edit that variable.
$dir = 'public://' . $config->get('javascript.directory');
// Delete old file, if we have no translations anymore, or a different file to be saved.
// Delete old file, if we have no translations anymore, or a different file to
// be saved.
$locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
$changed_hash = !isset($locale_javascripts[$language->id]) || ($locale_javascripts[$language->id] != $data_hash);
if (!empty($locale_javascripts[$language->id]) && (!$data || $changed_hash)) {
......@@ -1353,17 +1361,21 @@ function _locale_rebuild_js($langcode = NULL) {
case 'rebuilt':
$logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id]));
// Proceed to the 'created' case as the JavaScript translation file has
// been created again.
// Proceed to the 'created' case as the JavaScript translation file has
// been created again.
case 'created':
$logger->notice('Created JavaScript translation file for the language %language.', array('%language' => $language->name));
return TRUE;
case 'deleted':
$logger->notice('Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->name));
return TRUE;
case 'error':
$logger->error('An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->name));
return FALSE;
default:
// No operation needed.
return TRUE;
......
......@@ -9,6 +9,7 @@
* Comparison result of source files timestamps.
*
* Timestamp of source 1 is less than the timestamp of source 2.
*
* @see _locale_translation_source_compare()
*/
const LOCALE_TRANSLATION_SOURCE_COMPARE_LT = -1;
......@@ -17,6 +18,7 @@
* Comparison result of source files timestamps.
*
* Timestamp of source 1 is equal to the timestamp of source 2.
*
* @see _locale_translation_source_compare()
*/
const LOCALE_TRANSLATION_SOURCE_COMPARE_EQ = 0;
......@@ -25,6 +27,7 @@
* Comparison result of source files timestamps.
*
* Timestamp of source 1 is greater than the timestamp of source 2.
*
* @see _locale_translation_source_compare()
*/
const LOCALE_TRANSLATION_SOURCE_COMPARE_GT = 1;
......@@ -41,8 +44,8 @@
* disabled this function will return the last known module state. The status
* will only be updated once Update module is enabled.
*
* @params array $project_names
* Array of names of the projects to get.
* @param array $project_names
* Array of names of the projects to get.
*
* @return array
* Array of project data for translation update.
......@@ -107,7 +110,7 @@ function locale_translation_load_sources($projects = NULL, $langcodes = NULL) {
$status = locale_translation_get_status();
// Use only the selected projects and languages for update.
foreach($projects as $project) {
foreach ($projects as $project) {
foreach ($langcodes as $langcode) {
$sources[$project][$langcode] = isset($status[$project][$langcode]) ? $status[$project][$langcode] : NULL;
}
......@@ -158,7 +161,7 @@ function locale_translation_build_sources($projects = array(), $langcodes = arra
* @param object $source
* Translation source object.
*
* @return stdClass
* @return object
* Source file object of the po file, updated with:
* - "uri": File name and path.
* - "timestamp": Last updated time of the po file.
......@@ -203,8 +206,8 @@ function locale_translation_source_check_file($source) {
* - "files": Array of file objects containing properties of local and remote
* translation files.
* Other processes can add the following properties:
* - "type": Most recent translation source found. LOCALE_TRANSLATION_REMOTE and
* LOCALE_TRANSLATION_LOCAL indicate available new translations,
* - "type": Most recent translation source found. LOCALE_TRANSLATION_REMOTE
* and LOCALE_TRANSLATION_LOCAL indicate available new translations,
* LOCALE_TRANSLATION_CURRENT indicate that the current translation is them
* most recent. "type" sorresponds with a key of the "files" array.
* - "timestamp": The creation time of the "type" translation (file).
......@@ -367,7 +370,7 @@ function locale_cron_fill_queue() {
* @param string $uri
* The URI or URI pattern of the file.
*
* @return boolean
* @return bool
* TRUE if the $uri is a remote file.
*/
function _locale_translation_file_is_remote($uri) {
......@@ -389,7 +392,7 @@ function _locale_translation_file_is_remote($uri) {
* @param object $source2
* Source object of available update.
*
* @return integer
* @return int
* - "LOCALE_TRANSLATION_SOURCE_COMPARE_LT": $source1 < $source2 OR $source1
* is missing.
* - "LOCALE_TRANSLATION_SOURCE_COMPARE_EQ": $source1 == $source2 OR both
......
......@@ -115,11 +115,11 @@ public function buildForm(array $form, array &$form_state) {
}
$form['actions'] = array(
'#type' => 'actions'
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Export')
'#value' => $this->t('Export'),
);
return $form;
}
......@@ -137,13 +137,13 @@ public function submitForm(array &$form, array &$form_state) {
}
$content_options = isset($form_state['values']['content_options']) ? $form_state['values']['content_options'] : array();
$reader = new PoDatabaseReader();
$languageName = '';
$language_name = '';
if ($language != NULL) {
$reader->setLangcode($language->id);
$reader->setOptions($content_options);
$languages = $this->languageManager->getLanguages();
$languageName = isset($languages[$language->id]) ? $languages[$language->id]->name : '';
$filename = $language->id .'.po';
$language_name = isset($languages[$language->id]) ? $languages[$language->id]->name : '';
$filename = $language->id . '.po';
}
else {
// Template required.
......@@ -155,9 +155,9 @@ public function submitForm(array &$form, array &$form_state) {
$uri = tempnam('temporary://', 'po_');
$header = $reader->getHeader();
$header->setProjectName($this->config('system.site')->get('name'));
$header->setLanguageName($languageName);
$header->setLanguageName($language_name);
$writer = new PoStreamWriter;
$writer = new PoStreamWriter();
$writer->setUri($uri);
$writer->setHeader($header);
......
......@@ -109,7 +109,7 @@ public function buildForm(array $form, array &$form_state) {
'#theme' => 'file_upload_help',
'#description' => $this->t('A Gettext Portable Object file.'),
'#upload_validators' => $validators,
),
),
'#size' => 50,
'#upload_validators' => $validators,
'#attributes' => array('class' => array('file-import-input')),
......@@ -145,11 +145,11 @@ public function buildForm(array $form, array &$form_state) {
);
$form['actions'] = array(
'#type' => 'actions'
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Import')
'#value' => $this->t('Import'),
);
return $form;
}
......@@ -174,7 +174,7 @@ public function submitForm(array &$form, array &$form_state) {
$language = $this->languageManager->getLanguage($form_state['values']['langcode']);
if (empty($language)) {
$language = new Language(array(
'id' => $form_state['values']['langcode']
'id' => $form_state['values']['langcode'],
));
$language = language_save($language);
drupal_set_message($this->t('The language %language has been created.', array('%language' => $this->t($language->name))));
......
......@@ -108,12 +108,14 @@ public function submitForm(array &$form, array &$form_state) {
->set('translation.overwrite_not_customized', TRUE)
->save();
break;
case LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED:
$config
->set('translation.overwrite_customized', FALSE)
->set('translation.overwrite_not_customized', TRUE)
->save();
break;
case LOCALE_TRANSLATION_OVERWRITE_NONE:
$config
->set('translation.overwrite_customized', FALSE)
......@@ -122,8 +124,8 @@ public function submitForm(array &$form, array &$form_state) {
break;
}
// Invalidate the cached translation status when the configuration setting of
// 'use_source' changes.
// Invalidate the cached translation status when the configuration setting
// of 'use_source' changes.
if ($form['use_source']['#default_value'] != $form_state['values']['use_source']) {
locale_translation_clear_status();
}
......
......@@ -83,7 +83,7 @@ public function buildForm(array $form, array &$form_state) {
'#type' => 'item',
'#title' => $this->t('Singular form'),
'#markup' => '<span lang="en">' . String::checkPlain($source_array[0]) . '</span>',
'#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '</span>'
'#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '</span>',
);
$form['strings'][$string->lid]['original_plural'] = array(
'#type' => 'item',
......@@ -120,7 +120,7 @@ public function buildForm(array $form, array &$form_state) {
'#rows' => $rows,
'#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '',
'#attributes' => array('lang' => $langcode),
'#prefix' => $i == 0 ? ('<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>') : '',
'#prefix' => $i == 0 ? ('<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>') : '',
);
}
}
......@@ -132,7 +132,7 @@ public function buildForm(array $form, array &$form_state) {
'#rows' => $rows,
'#default_value' => $translation_array[0],
'#attributes' => array('lang' => $langcode),
'#prefix' => '<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>',
'#prefix' => '<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>',
);
$form['strings'][$string->lid]['translations'][1] = array(
'#type' => 'textarea',
......@@ -189,7 +189,8 @@ public function submitForm(array &$form, array &$form_state) {
$existing_translation = isset($existing_translation_objects[$lid]);
// Plural translations are saved in a delimited string. To be able to
// compare the new strings with the existing strings a string in the same format is created.
// compare the new strings with the existing strings a string in the same
// format is created.
$new_translation_string_delimited = implode(LOCALE_PLURAL_DELIMITER, $new_translation['translations']);
// Generate an imploded string without delimiter, to be able to run
......
......@@ -120,7 +120,7 @@ protected function translateFilterLoadStrings() {
* @param bool $reset
* If the list of values should be reset.
*
* @return array $filter_values
* @return array
* The filter values.
*/
protected function translateFilterValues($reset = FALSE) {
......
......@@ -46,7 +46,7 @@ class Gettext {
*
* @see \Drupal\locale\PoDatabaseWriter
*/
static function fileToDatabase($file, $options) {
public static function fileToDatabase($file, $options) {
// Add the default values to the options array.
$options += array(
'overwrite_options' => array(),
......
......@@ -68,24 +68,24 @@ class LocaleConfigManager {
/**
* Creates a new typed configuration manager.
*
* @param \Drupal\Core\Config\StorageInterface $configStorage
* @param \Drupal\Core\Config\StorageInterface $config_storage
* The storage object to use for reading configuration data.
* @param \Drupal\Core\Config\StorageInterface $installStorage
* @param \Drupal\Core\Config\StorageInterface $install_storage
* The storage object to use for reading default configuration
* data.
* @param \Drupal\locale\StringStorageInterface $localeStorage
* @param \Drupal\locale\StringStorageInterface $locale_storage
* The locale storage to use for reading string translations.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config
* The typed configuration manager.
* @param \Drupal\language\ConfigurableLanguageManagerInterface
* @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager
* The language manager.
*/
public function __construct(StorageInterface $configStorage, StorageInterface $installStorage, StringStorageInterface $localeStorage, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, ConfigurableLanguageManagerInterface $language_manager) {
$this->configStorage = $configStorage;
$this->installStorage = $installStorage;
$this->localeStorage = $localeStorage;
public function __construct(StorageInterface $config_storage, StorageInterface $install_storage, StringStorageInterface $locale_storage, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, ConfigurableLanguageManagerInterface $language_manager) {
$this->configStorage = $config_storage;
$this->installStorage = $install_storage;
$this->localeStorage = $locale_storage;
$this->configFactory = $config_factory;
$this->typedConfigManager = $typed_config;
$this->languageManager = $language_manager;
......@@ -273,7 +273,7 @@ public function translateString($name, $langcode, $source, $context) {
if (!isset($this->translations[$name][$langcode])) {
// Preload all translations for this configuration name and language.
$this->translations[$name][$langcode] = array();
foreach ($this->localeStorage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => $name)) as $string){
foreach ($this->localeStorage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => $name)) as $string) {
$this->translations[$name][$langcode][$string->context][$string->source] = $string;
}
}
......
......@@ -119,7 +119,7 @@ protected function resolveCacheMiss($offset) {
$this->stringStorage->createString(array(
'source' => $offset,
'context' => $this->context,
'version' => \Drupal::VERSION
'version' => \Drupal::VERSION,
))->addLocation('path', $this->requestUri())->save();
$value = TRUE;
}
......@@ -129,7 +129,7 @@ protected function resolveCacheMiss($offset) {
if ($value === TRUE) {
$fallbacks = $this->languageManager->getFallbackCandidates($this->langcode, array('operation' => 'locale_lookup', 'data' => $offset));
if (!empty($fallbacks)) {
foreach($fallbacks as $langcode) {
foreach ($fallbacks as $langcode) {
$translation = $this->stringStorage->findTranslation(array(
'language' => $langcode,
'source' => $offset,
......
......@@ -38,7 +38,7 @@ class LocaleTranslation implements TranslatorInterface, DestructableInterface {
protected $configFactory;
/**
* Cached translations
* Cached translations.
*
* @var array
* Array of \Drupal\locale\LocaleLookup objects indexed by language code
......
......@@ -55,13 +55,13 @@ class LocaleTypedConfig extends Element {
* The configuration object name.
* @param string $langcode
* Language code for the source configuration data.
* @param \Drupal\locale\LocaleConfigManager $localeConfig;
* @param \Drupal\locale\LocaleConfigManager $locale_config
* The locale configuration manager object.
*/
public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $localeConfig, TypedConfigManagerInterface $typed_config) {
public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $locale_config, TypedConfigManagerInterface $typed_config) {
parent::__construct($definition, $name);
$this->langcode = $langcode;
$this->localeConfig = $localeConfig;
$this->localeConfig = $locale_config;
$this->typedConfigManager = $typed_config;
}
......@@ -117,7 +117,7 @@ protected function canTranslate($from_langcode, $to_langcode) {
* \Drupal\Core\Config\Schema\ArrayElement.
* @param array $options
* Array with translation options that must contain the keys defined in
* \Drupal\locale\LocaleTypedConfig::translateElement()
* \Drupal\locale\LocaleTypedConfig::translateElement().
*
* @return array
* Configuration data translated to the requested language if available,
......@@ -141,7 +141,7 @@ protected function getElementTranslation($element, array $options) {
* Typed configuration array element.
* @param array $options
* Array with translation options that must contain the keys defined in
* \Drupal\locale\LocaleTypedConfig::translateElement()
* \Drupal\locale\LocaleTypedConfig::translateElement().