You are here

function locale_translation_check_projects_local in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.compare.inc \locale_translation_check_projects_local()
  2. 9 core/modules/locale/locale.compare.inc \locale_translation_check_projects_local()

Check and store the status and timestamp of local po files.

Only po files in the local file system are checked. Any remote translation files will be ignored.

Projects may contain a server_pattern option containing a pattern of the path to the po source files. If no server_pattern is defined the default translation directory is checked for the po file. When a server_pattern is defined the specified location is checked. The server_pattern can be set in the module's .info.yml file or by using hook_locale_translation_projects_alter().

Parameters

array $projects: Array of project names for which to check the state of translation files. Defaults to all translatable projects.

array $langcodes: Array of language codes. Defaults to all translatable languages.

2 calls to locale_translation_check_projects_local()
locale_translation_check_projects in core/modules/locale/locale.compare.inc
Check for the latest release of project translations.
_install_prepare_import in core/includes/install.core.inc
Tells the translation import process that Drupal core is installed.

File

core/modules/locale/locale.compare.inc, line 301
The API for comparing project translation status with available translation.

Code

function locale_translation_check_projects_local($projects = [], $langcodes = []) {
  $projects = locale_translation_get_projects($projects);
  $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());

  // For each project and each language we check if a local po file is
  // available. When found the source object is updated with the appropriate
  // type and timestamp of the po file.
  foreach ($projects as $name => $project) {
    foreach ($langcodes as $langcode) {
      $source = locale_translation_source_build($project, $langcode);
      $file = locale_translation_source_check_file($source);
      locale_translation_status_save($name, $langcode, LOCALE_TRANSLATION_LOCAL, $file);
    }
  }
}