function install_find_translations
Same name in other branches
- 9 core/includes/install.core.inc \install_find_translations()
- 8.9.x core/includes/install.core.inc \install_find_translations()
- 10 core/includes/install.core.inc \install_find_translations()
Finds all .po files that are useful to the installer.
Return value
array An associative array of file URIs keyed by language code. URIs as returned by FileSystemInterface::scanDirectory().
See also
\Drupal\Core\File\FileSystemInterface::scanDirectory()
1 call to install_find_translations()
- install_select_language in core/
includes/ install.core.inc - Selects which language to use during installation.
File
-
core/
includes/ install.core.inc, line 1327
Code
function install_find_translations() {
$translations = [];
$files = \Drupal::service('string_translator.file_translation')->findTranslationFiles();
// English does not need a translation file.
array_unshift($files, (object) [
'name' => 'en',
]);
foreach ($files as $uri => $file) {
// Strip off the file name component before the language code.
$langcode = preg_replace('!^(.+\\.)?([^\\.]+)$!', '\\2', $file->name);
// Language codes cannot exceed 12 characters to fit into the {language}
// table.
if (strlen($langcode) <= 12) {
$translations[$langcode] = $uri;
}
}
return $translations;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.