You are here

function l10n_update_get_interface_translation_files in Localization update 7.2

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 languages.

Return value

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

2 calls to l10n_update_get_interface_translation_files()
l10n_update_batch_import_files in ./l10n_update.bulk.inc
Prepare a batch to import all translations.
l10n_update_delete_translation_files in ./l10n_update.bulk.inc
Deletes interface translation files and translation history records.

File

./l10n_update.bulk.inc, line 340
Mass import-export and batch import functionality for Gettext .po files.

Code

function l10n_update_get_interface_translation_files($projects = array(), $langcodes = array()) {
  module_load_include('compare.inc', 'l10n_update');
  $files = array();
  $projects = $projects ? $projects : array_keys(l10n_update_get_projects());
  $langcodes = $langcodes ? $langcodes : array_keys(l10n_update_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 = variable_get('l10n_update_download_store', L10N_UPDATE_DEFAULT_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 = l10n_update_file_attach_properties($file);
    if (in_array($file->project, $projects)) {
      if (in_array($file->langcode, $langcodes)) {
        $files[$file->uri] = $file;
      }
    }
  }
  return $files;
}