Commit 12c2fbbe authored by alexpott's avatar alexpott
Browse files

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 @@ ...@@ -45,7 +45,8 @@
* Multiple custom modules or themes sharing the same po file should have * Multiple custom modules or themes sharing the same po file should have
* matching definitions. Such as modules and sub-modules or multiple modules in * matching definitions. Such as modules and sub-modules or multiple modules in
* the same project/code tree. Both "interface translation project" and * 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 * Example .info.yml file properties for a custom module with a po file located
* on a remote translation server. * on a remote translation server.
...@@ -109,7 +110,7 @@ ...@@ -109,7 +110,7 @@
* @param array $projects * @param array $projects
* Project data as returned by update_get_projects(). * Project data as returned by update_get_projects().
* *
* @see locale_translation_project_list(). * @see locale_translation_project_list()
* @ingroup interface_translation_properties * @ingroup interface_translation_properties
*/ */
function hook_locale_translation_projects_alter(&$projects) { function hook_locale_translation_projects_alter(&$projects) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @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; use GuzzleHttp\Exception\RequestException;
...@@ -85,7 +85,7 @@ function locale_translation_batch_status_check($project, $langcode, $options = a ...@@ -85,7 +85,7 @@ function locale_translation_batch_status_check($project, $langcode, $options = a
/** /**
* Batch finished callback: Set result message. * Batch finished callback: Set result message.
* *
* @param boolean $success * @param bool $success
* TRUE if batch successfully completed. * TRUE if batch successfully completed.
* @param array $results * @param array $results
* Batch results. * Batch results.
...@@ -93,13 +93,13 @@ function locale_translation_batch_status_check($project, $langcode, $options = a ...@@ -93,13 +93,13 @@ function locale_translation_batch_status_check($project, $langcode, $options = a
function locale_translation_batch_status_finished($success, $results) { function locale_translation_batch_status_finished($success, $results) {
if ($success) { if ($success) {
if (isset($results['failed_files'])) { if (isset($results['failed_files'])) {
if (\Drupal::moduleHandler()->moduleExists('dblog')) { 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'))); $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 { 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.'); $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'); drupal_set_message($message, 'error');
} }
if (isset($results['files'])) { if (isset($results['files'])) {
drupal_set_message(format_plural( drupal_set_message(format_plural(
...@@ -201,9 +201,9 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$ ...@@ -201,9 +201,9 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
/** /**
* Batch finished callback: Set result message. * Batch finished callback: Set result message.
* *
* @param boolean $success * @param bool $success
* TRUE if batch successfully completed. * TRUE if batch successfully completed.
* @param array * @param array $results
* Batch results. * Batch results.
*/ */
function locale_translation_batch_fetch_finished($success, $results) { function locale_translation_batch_fetch_finished($success, $results) {
...@@ -220,7 +220,7 @@ function locale_translation_batch_fetch_finished($success, $results) { ...@@ -220,7 +220,7 @@ function locale_translation_batch_fetch_finished($success, $results) {
* @param string $uri * @param string $uri
* URI of remote file. * URI of remote file.
* *
* @return array|boolean * @return array|bool
* Associative array of file data with the following elements: * Associative array of file data with the following elements:
* - last_modified: Last modified timestamp of the translation file. * - last_modified: Last modified timestamp of the translation file.
* - (optional) location: The location of the translation file. Is only set * - (optional) location: The location of the translation file. Is only set
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
* LOCALE_NOT_CUSTOMIZED. * LOCALE_NOT_CUSTOMIZED.
* - 'finish_feedback': Whether or not to give feedback to the user when the * - 'finish_feedback': Whether or not to give feedback to the user when the
* batch is finished. Optional, defaults to TRUE. * batch is finished. Optional, defaults to TRUE.
*
* @param $force * @param $force
* (optional) Import all available files, even if they were imported before. * (optional) Import all available files, even if they were imported before.
* *
...@@ -75,8 +74,8 @@ function locale_translate_batch_import_files($options, $force = FALSE) { ...@@ -75,8 +74,8 @@ function locale_translate_batch_import_files($options, $force = FALSE) {
* Project names from which to get the translation files and history. * Project names from which to get the translation files and history.
* Defaults to all projects. * Defaults to all projects.
* @param array $langcodes * @param array $langcodes
* Language codes from which to get the translation files and history. * Language codes from which to get the translation files and history.
* Defaults to all languagues * Defaults to all languages.
* *
* @return array * @return array
* An array of interface translation files keyed by their URI. * An array of interface translation files keyed by their URI.
...@@ -112,7 +111,6 @@ function locale_translate_get_interface_translation_files($projects = array(), $ ...@@ -112,7 +111,6 @@ function locale_translate_get_interface_translation_files($projects = array(), $
* *
* @param $files * @param $files
* Array of file objects to import. * Array of file objects to import.
*
* @param array $options * @param array $options
* An array with options that can have the following elements: * An array with options that can have the following elements:
* - 'langcode': The language code. Optional, defaults to NULL, which means * - 'langcode': The language code. Optional, defaults to NULL, which means
...@@ -142,7 +140,7 @@ function locale_translate_batch_build($files, $options) { ...@@ -142,7 +140,7 @@ function locale_translate_batch_build($files, $options) {
$operations[] = array('locale_translate_batch_import', array($file, $options)); $operations[] = array('locale_translate_batch_import', array($file, $options));
} }
// Save the translation status of all files. // 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. // Add a final step to refresh JavaScript and configuration strings.
$operations[] = array('locale_translate_batch_refresh', array()); $operations[] = array('locale_translate_batch_refresh', array());
...@@ -167,10 +165,9 @@ function locale_translate_batch_build($files, $options) { ...@@ -167,10 +165,9 @@ function locale_translate_batch_build($files, $options) {
* *
* @param object $file * @param object $file
* A file object of the gettext file to be imported. The file object must * A file object of the gettext file to be imported. The file object must
* contain a language parameter * contain a language parameter (other than
* (other than LanguageInterface::LANGCODE_NOT_SPECIFIED). This is used as * LanguageInterface::LANGCODE_NOT_SPECIFIED). This is used as the language of
* the language of the import. * the import.
*
* @param array $options * @param array $options
* An array with options that can have the following elements: * An array with options that can have the following elements:
* - 'langcode': The language code. * - 'langcode': The language code.
...@@ -182,7 +179,6 @@ function locale_translate_batch_build($files, $options) { ...@@ -182,7 +179,6 @@ function locale_translate_batch_build($files, $options) {
* LOCALE_NOT_CUSTOMIZED. * LOCALE_NOT_CUSTOMIZED.
* - 'message': Alternative message to display during import. Note, this must * - 'message': Alternative message to display during import. Note, this must
* be sanitized text. * be sanitized text.
*
* @param $context * @param $context
* Contains a list of files imported. * Contains a list of files imported.
*/ */
...@@ -474,9 +470,9 @@ function locale_translate_file_attach_properties($file, $options = array()) { ...@@ -474,9 +470,9 @@ function locale_translate_file_attach_properties($file, $options = array()) {
* Defaults to all projects. * Defaults to all projects.
* @param array $langcodes * @param array $langcodes
* Language codes from which to delete the translation files and history. * 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 * TRUE if files are removed successfully. FALSE if one or more files could
* not be deleted. * not be deleted.
*/ */
...@@ -543,10 +539,10 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar ...@@ -543,10 +539,10 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar
foreach ($names as $name) { foreach ($names as $name) {
$batch_names[] = $name; $batch_names[] = $name;
$i++; $i++;
// During installation the caching of configuration objects is disabled // During installation the caching of configuration objects is disabled so
// so it is very expensive to initialize the \Drupal::config() object on each request. // it is very expensive to initialize the \Drupal::config() object on each
// We batch a small number of configuration object upgrades together to // request. We batch a small number of configuration object upgrades
// improve the overall performance of the process. // together to improve the overall performance of the process.
if ($i % 20 == 0) { if ($i % 20 == 0) {
$operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes)); $operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes));
$batch_names = array(); $batch_names = array();
...@@ -571,7 +567,7 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar ...@@ -571,7 +567,7 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar
/** /**
* Performs configuration translation refresh as a batch step. * Performs configuration translation refresh as a batch step.
* *
* @param string $name * @param string $names
* Name of configuration object to update. * Name of configuration object to update.
* @param array $langcodes * @param array $langcodes
* (optional) Array of language codes to update. Defaults to all languages. * (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 ...@@ -595,12 +591,12 @@ function locale_config_batch_refresh_name(array $names, array $langcodes, array
/** /**
* Finishes callback of system page locale import batch. * Finishes callback of system page locale import batch.
* *
* @see locale_config_batch_build()
*
* @param bool $success * @param bool $success
* Information about the success of the batch import. * Information about the success of the batch import.
* @param array $results * @param array $results
* Information about the results of the batch import. * Information about the results of the batch import.
*
* @see locale_config_batch_build()
*/ */
function locale_config_batch_finished($success, array $results) { function locale_config_batch_finished($success, array $results) {
if ($success) { if ($success) {
......
...@@ -114,8 +114,8 @@ function locale_translation_build_projects() { ...@@ -114,8 +114,8 @@ function locale_translation_build_projects() {
)) ))
->execute(); ->execute();
// Invalidate the cache of translatable projects. // Invalidate the cache of translatable projects.
locale_translation_clear_cache_projects(); locale_translation_clear_cache_projects();
} }
return $projects; return $projects;
} }
...@@ -193,7 +193,8 @@ function _locale_translation_prepare_project_list($data, $type) { ...@@ -193,7 +193,8 @@ function _locale_translation_prepare_project_list($data, $type) {
function locale_translation_default_translation_server() { function locale_translation_default_translation_server() {
$pattern = \Drupal::config('locale.settings')->get('translation.default_server_pattern'); $pattern = \Drupal::config('locale.settings')->get('translation.default_server_pattern');
// An additional check is required here. During the upgrade process // 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; $pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN;
return array( return array(
...@@ -211,8 +212,9 @@ function locale_translation_default_translation_server() { ...@@ -211,8 +212,9 @@ function locale_translation_default_translation_server() {
* *
* @return array * @return array
* Available sources indexed by project and language. * 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()) { function locale_translation_check_projects($projects = array(), $langcodes = array()) {
if (locale_translation_use_remote_source()) { if (locale_translation_use_remote_source()) {
// Retrieve the status of both remote and local translation sources by // Retrieve the status of both remote and local translation sources by
......
...@@ -123,7 +123,7 @@ function locale_schema() { ...@@ -123,7 +123,7 @@ function locale_schema() {
), ),
), ),
'indexes' => array( 'indexes' => array(
'lid' => array('lid'), 'lid' => array('lid'),
), ),
); );
...@@ -170,8 +170,8 @@ function locale_schema() { ...@@ -170,8 +170,8 @@ function locale_schema() {
), ),
), ),
'indexes' => array( 'indexes' => array(
'string_id' => array('sid'), 'string_id' => array('sid'),
'string_type' => array('sid', 'type'), 'string_type' => array('sid', 'type'),
), ),
); );
......
...@@ -155,13 +155,14 @@ function locale_help($route_name, RouteMatchInterface $route_match) { ...@@ -155,13 +155,14 @@ function locale_help($route_name, RouteMatchInterface $route_match) {
return $output; return $output;
case 'language.admin_overview': 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': 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>'; $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; return $output;
case 'locale.translate_import': 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('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>'; $output .= '<p>' . t('Note that importing large .po files may take several minutes.') . '</p>';
return $output; return $output;
...@@ -290,6 +291,7 @@ function locale_translatable_language_list() { ...@@ -290,6 +291,7 @@ function locale_translatable_language_list() {
* @param $langcode * @param $langcode
* Optional language code to translate to a language other than * Optional language code to translate to a language other than
* what is used to display the page. * what is used to display the page.
*
* @return * @return
* The numeric index of the plural variant to use for this $langcode and * 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 * $count combination or -1 if the language was not found or does not have a
...@@ -412,7 +414,7 @@ function locale_queue_info() { ...@@ -412,7 +414,7 @@ function locale_queue_info() {
* queue data. * queue data.
* *
* @param array $data * @param array $data
* Queue data array containing: * Queue data array containing:
* - Function name. * - Function name.
* - Array of function arguments. Optionally contains the batch context data. * - Array of function arguments. Optionally contains the batch context data.
* *
...@@ -481,7 +483,8 @@ function locale_system_update(array $components) { ...@@ -481,7 +483,8 @@ function locale_system_update(array $components) {
$projects = array_keys(locale_translation_build_projects()); $projects = array_keys(locale_translation_build_projects());
if ($list = array_intersect($list, $projects)) { if ($list = array_intersect($list, $projects)) {
module_load_include('fetch.inc', 'locale'); 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(); $options = _locale_translation_default_update_options();
$batch = locale_translation_batch_update_build($list, array(), $options); $batch = locale_translation_batch_update_build($list, array(), $options);
batch_set($batch); batch_set($batch);
...@@ -514,7 +517,8 @@ function locale_system_remove($components) { ...@@ -514,7 +517,8 @@ function locale_system_remove($components) {
\Drupal\locale\Locale::config()->deleteComponentTranslations($components, array_keys($language_list)); \Drupal\locale\Locale::config()->deleteComponentTranslations($components, array_keys($language_list));
// Only when projects are removed, the translation files and records will be // 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()); $projects = array_keys(locale_translation_get_projects());
if ($list = array_intersect($list, $projects)) { if ($list = array_intersect($list, $projects)) {
locale_translation_file_history_delete($list); locale_translation_file_history_delete($list);
...@@ -561,6 +565,7 @@ function locale_js_alter(&$javascript) { ...@@ -561,6 +565,7 @@ function locale_js_alter(&$javascript) {
* *
* @param array $files * @param array $files
* An array of local file paths. * An array of local file paths.
*
* @return string|null * @return string|null
* The filepath to the translation file or NULL if no translation is * The filepath to the translation file or NULL if no translation is
* applicable. * applicable.
...@@ -693,7 +698,7 @@ function locale_form_language_admin_overview_form_alter(&$form, &$form_state) { ...@@ -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) { function locale_form_language_admin_add_form_alter(&$form, &$form_state) {
$form['predefined_submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit'; $form['predefined_submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit';
...@@ -847,7 +852,7 @@ function locale_translation_get_file_history() { ...@@ -847,7 +852,7 @@ function locale_translation_get_file_history() {
* @param object $file * @param object $file
* Object representing the file just imported. * Object representing the file just imported.
* *
* @return integer * @return int
* FALSE on failure. Otherwise SAVED_NEW or SAVED_UPDATED. * FALSE on failure. Otherwise SAVED_NEW or SAVED_UPDATED.
*/ */
function locale_translation_update_file_history($file) { function locale_translation_update_file_history($file) {
...@@ -874,7 +879,7 @@ function locale_translation_update_file_history($file) { ...@@ -874,7 +879,7 @@ function locale_translation_update_file_history($file) {
* @param array $projects * @param array $projects
* Project name(s) to be deleted from the file history. If both project(s) and * 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. * 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. * Language code(s) to be deleted from the file history.
*/ */
function locale_translation_file_history_delete($projects = array(), $langcodes = array()) { function locale_translation_file_history_delete($projects = array(), $langcodes = array()) {
...@@ -963,6 +968,7 @@ function locale_translation_status_save($project, $langcode, $type, $data) { ...@@ -963,6 +968,7 @@ function locale_translation_status_save($project, $langcode, $type, $data) {
} }
} }
break; break;
case LOCALE_TRANSLATION_CURRENT: case LOCALE_TRANSLATION_CURRENT:
$data->last_checked = REQUEST_TIME; $data->last_checked = REQUEST_TIME;
$status[$project][$langcode]->timestamp = $data->timestamp; $status[$project][$langcode]->timestamp = $data->timestamp;
...@@ -1200,7 +1206,8 @@ function _locale_parse_js_file($filepath) { ...@@ -1200,7 +1206,8 @@ function _locale_parse_js_file($filepath) {
$source = \Drupal::service('locale.storage')->findString($match); $source = \Drupal::service('locale.storage')->findString($match);
if (!$source) { 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); $source = \Drupal::service('locale.storage')->createString($match);
} }
...@@ -1267,7 +1274,7 @@ function _locale_rebuild_js($langcode = NULL) { ...@@ -1267,7 +1274,7 @@ function _locale_rebuild_js($langcode = NULL) {
// Only add strings with a translation to the translations array. // Only add strings with a translation to the translations array.
$conditions = array( $conditions = array(
'type' => 'javascript', 'type' => 'javascript',
'language' => $language->id, 'language' => $language->id,
'translated' => TRUE, 'translated' => TRUE,
); );
$translations = array(); $translations = array();
...@@ -1296,7 +1303,8 @@ function _locale_rebuild_js($langcode = NULL) { ...@@ -1296,7 +1303,8 @@ function _locale_rebuild_js($langcode = NULL) {
// There is (on purpose) no front end to edit that variable. // There is (on purpose) no front end to edit that variable.
$dir = 'public://' . $config->get('javascript.directory'); $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(); $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
$changed_hash = !isset($locale_javascripts[$language->id]) || ($locale_javascripts[$language->id] != $data_hash); $changed_hash = !isset($locale_javascripts[$language->id]) || ($locale_javascripts[$language->id] != $data_hash);
if (!empty($locale_javascripts[$language->id]) && (!$data || $changed_hash)) { if (!empty($locale_javascripts[$language->id]) && (!$data || $changed_hash)) {
...@@ -1353,17 +1361,21 @@ function _locale_rebuild_js($langcode = NULL) { ...@@ -1353,17 +1361,21 @@ function _locale_rebuild_js($langcode = NULL) {
case 'rebuilt': case 'rebuilt':
$logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id])); $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 // Proceed to the 'created' case as the JavaScript translation file has
// been created again. // been created again.
case 'created': case 'created':
$logger->notice('Created JavaScript translation file for the language %language.', array('%language' => $language->name)); $logger->notice('Created JavaScript translation file for the language %language.', array('%language' => $language->name));
return TRUE; return TRUE;
case 'deleted': case 'deleted':
$logger->notice('Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->name)); $logger->notice('Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->name));
return TRUE; return TRUE;
case 'error': case 'error':
$logger->error('An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->name)); $logger->error('An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->name));
return FALSE; return FALSE;
default: default:
// No operation needed. // No operation needed.
return TRUE; return TRUE;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* Comparison result of source files timestamps. * Comparison result of source files timestamps.
* *
* Timestamp of source 1 is less than the timestamp of source 2. * Timestamp of source 1 is less than the timestamp of source 2.
*
* @see _locale_translation_source_compare() * @see _locale_translation_source_compare()
*/ */
const LOCALE_TRANSLATION_SOURCE_COMPARE_LT = -1; const LOCALE_TRANSLATION_SOURCE_COMPARE_LT = -1;
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
* Comparison result of source files timestamps. * Comparison result of source files timestamps.
* *
* Timestamp of source 1 is equal to the timestamp of source 2. * Timestamp of source 1 is equal to the timestamp of source 2.
*
* @see _locale_translation_source_compare() * @see _locale_translation_source_compare()
*/ */
const LOCALE_TRANSLATION_SOURCE_COMPARE_EQ = 0; const LOCALE_TRANSLATION_SOURCE_COMPARE_EQ = 0;
...@@ -25,6 +27,7 @@ ...@@ -25,6 +27,7 @@
* Comparison result of source files timestamps. * Comparison result of source files timestamps.
* *
* Timestamp of source 1 is greater than the timestamp of source 2. * Timestamp of source 1 is greater than the timestamp of source 2.
*
* @see _locale_translation_source_compare() * @see _locale_translation_source_compare()
*/ */
const LOCALE_TRANSLATION_SOURCE_COMPARE_GT = 1; const LOCALE_TRANSLATION_SOURCE_COMPARE_GT = 1;
...@@ -41,8 +44,8 @@ ...@@ -41,8 +44,8 @@
* disabled this function will return the last known module state. The status * disabled this function will return the last known module state. The status
* will only be updated once Update module is enabled. * will only be updated once Update module is enabled.
* *
* @params array $project_names * @param array $project_names
* Array of names of the projects to get. * Array of names of the projects to get.
* *
* @return array