function locale_translate_get_interface_translation_files

Get interface translation files present in the translations directory.

Parameters

array $projects: Project names from which to get the translation files and history. Defaults to all projects.

array $langcodes: Language codes from which to get the translation files and history. Defaults to all languagues

Return value

array An array of interface translation files keyed by their URI.

2 calls to locale_translate_get_interface_translation_files()
locale_translate_batch_import_files in drupal/core/modules/locale/locale.bulk.inc
Prepare a batch to import all translations.
locale_translate_delete_translation_files in drupal/core/modules/locale/locale.bulk.inc
Deletes interface translation files and translation history records.

File

drupal/core/modules/locale/locale.bulk.inc, line 340
Mass import-export and batch import functionality for Gettext .po files.

Code

function locale_translate_get_interface_translation_files($projects = array(), $langcodes = array()) {
  module_load_include('compare.inc', 'locale');
  $files = array();
  $projects = $projects ? $projects : array_keys(locale_translation_get_projects());
  $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());

  // Scan the translations directory for files matching a name pattern
  // containing a project name and language code: {project}.{langcode}.po or
  // {project}-{version}.{langcode}.po.
  // Only files of known projects and languages will be returned.
  $directory = config('locale.settings')
    ->get('translation.path');
  $result = file_scan_directory($directory, '![a-z_]+(\\-[0-9a-z\\.\\-\\+]+|)\\.[^\\./]+\\.po$!', array(
    'recurse' => FALSE,
  ));
  foreach ($result as $file) {

    // Update the file object with project name and version from the file name.
    $file = locale_translate_file_attach_properties($file);
    if (in_array($file->project, $projects)) {
      if (in_array($file->langcode, $langcodes)) {
        $files[$file->uri] = $file;
      }
    }
  }
  return $files;
}