protected function FileTranslation::getLanguage in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php \Drupal\Core\StringTranslation\Translator\FileTranslation::getLanguage()
- 9 core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php \Drupal\Core\StringTranslation\Translator\FileTranslation::getLanguage()
Retrieves translations for a given language.
Parameters
string $langcode: The langcode of the language.
Return value
array A multidimensional array of translations, indexed by the context the source string belongs to. The second level is using original strings as keys. An empty array will be returned when no translations are available.
Overrides StaticTranslation::getLanguage
File
- core/
lib/ Drupal/ Core/ StringTranslation/ Translator/ FileTranslation.php, line 51
Class
- FileTranslation
- File based string translation.
Namespace
Drupal\Core\StringTranslation\TranslatorCode
protected function getLanguage($langcode) {
// If the given langcode was selected, there should be at least one .po
// file with its name in the pattern drupal-$version.$langcode.po.
// This might or might not be the entire filename. It is also possible
// that multiple files end with the same suffix, even if unlikely.
$files = $this
->findTranslationFiles($langcode);
if (!empty($files)) {
return $this
->filesToArray($langcode, $files);
}
else {
return [];
}
}