FileTranslation
class FileTranslation extends StaticTranslation (View source)
File based string translation.
Translates a string when some systems are not available.
Used during the install process, when database, theme, and localization system is possibly not yet available.
Properties
| protected array | $translations | String translations. |
from StaticTranslation |
| protected string | $directory | Directory to find translation files in the file system. |
|
| protected FileSystemInterface | $fileSystem | The file system. |
Methods
Constructs a StaticTranslation object.
Retrieves English string to given language.
Retrieves translations for a given language.
Finds installer translations either for a specific or all languages.
Provides translation file name pattern.
Reads the given Gettext PO files into a data structure.
Details
__construct(string $directory, FileSystemInterface $file_system)
Constructs a StaticTranslation object.
string|false
getStringTranslation(string $langcode, string $string, string $context)
Retrieves English string to given language.
reset()
Resets translation cache.
Since most translation systems implement some form of caching, this provides a way to delete that cache.
protected array
getLanguage(string $langcode)
Retrieves translations for a given language.
array
findTranslationFiles(string $langcode = NULL)
Finds installer translations either for a specific or all languages.
Filenames must match the pattern:
- 'drupal-[version].[langcode].po (if langcode is provided)
- 'drupal-[version].*.po (if no langcode is provided)
protected string
getTranslationFilesPattern(string $langcode = NULL)
Provides translation file name pattern.
static array
filesToArray(string $langcode, array $files)
Reads the given Gettext PO files into a data structure.