function locale_translate_file_attach_properties
Same name and namespace in other branches
- 10 core/modules/locale/locale.bulk.inc \locale_translate_file_attach_properties()
- 11.x core/modules/locale/locale.bulk.inc \locale_translate_file_attach_properties()
- 9 core/modules/locale/locale.bulk.inc \locale_translate_file_attach_properties()
- 8.9.x core/modules/locale/locale.bulk.inc \locale_translate_file_attach_properties()
Generates file properties from filename and options.
An attempt is made to determine the translation language, project name and project version from the file name. Supported file name patterns are: {project}-{version}.{langcode}.po, {prefix}.{langcode}.po or {langcode}.po. Alternatively the translation language can be set using the $options.
Parameters
object $file: A file object of the gettext file to be imported.
array $options: An array with options:
- 'langcode': The language code. Overrides the file language.
Return value
object Modified file object.
Deprecated
in drupal:11.4.0 and is removed from drupal:13.0.0. Use LocaleFile::createFromPath($filename, $uri, $langCodeOverride) instead.
See also
https://www.drupal.org/node/3577675
File
-
core/
modules/ locale/ locale.bulk.inc, line 405
Code
function locale_translate_file_attach_properties($file, array $options = []) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use LocaleFile::createFromPath($filename, $uri, $langCodeOverride) instead. See https://www.drupal.org/node/3577675', E_USER_DEPRECATED);
if ($file instanceof FileInterface) {
$uri = $file->getFileUri();
$filename = $file->getFilename();
}
else {
$uri = $file->uri;
$filename = $file->filename;
$options['langcode'] = LanguageInterface::LANGCODE_NOT_SPECIFIED;
}
return LocaleFile::createFromPath($filename, $uri, $options['langcode']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.