Get interface translation files present in the translations directory.
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
array An array of interface translation files keyed by their URI.
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;
}