locale_translate_get_interface_translation_files(array $projects = array(), array $langcodes = array())
Get interface translation files present in the translations directory.
Parameters
array $projects: (optional) Project names from which to get the translation files and history. Defaults to all projects.
array $langcodes: (optional) 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.
File
- core/modules/locale/locale.bulk.inc, line 87
- Mass import-export and batch import functionality for Gettext .po files.
Code
function locale_translate_get_interface_translation_files(array $projects = array(), 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 = \Drupal::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; }
Please login to continue.