public static function FileTranslation::filesToArray in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php \Drupal\Core\StringTranslation\Translator\FileTranslation::filesToArray()
- 9 core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php \Drupal\Core\StringTranslation\Translator\FileTranslation::filesToArray()
Reads the given Gettext PO files into a data structure.
Parameters
string $langcode: Language code string.
array $files: List of file objects with URI properties pointing to read.
Return value
array Structured array as produced by a PoMemoryWriter.
See also
\Drupal\Component\Gettext\PoMemoryWriter
1 call to FileTranslation::filesToArray()
- FileTranslation::getLanguage in core/
lib/ Drupal/ Core/ StringTranslation/ Translator/ FileTranslation.php - Retrieves translations for a given language.
File
- core/
lib/ Drupal/ Core/ StringTranslation/ Translator/ FileTranslation.php, line 122
Class
- FileTranslation
- File based string translation.
Namespace
Drupal\Core\StringTranslation\TranslatorCode
public static function filesToArray($langcode, array $files) {
$writer = new PoMemoryWriter();
$writer
->setLangcode($langcode);
foreach ($files as $file) {
$reader = new PoStreamReader();
$reader
->setURI($file->uri);
$reader
->setLangcode($langcode);
$reader
->open();
$writer
->writeItems($reader, -1);
}
return $writer
->getData();
}