Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,22 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode)
->prototype('scalar')->end()
->defaultValue([])
->end()
->arrayNode('pseudo_localization')
->canBeEnabled()
->fixXmlConfig('localizable_html_attribute')
->children()
->booleanNode('accents')->defaultTrue()->end()
->floatNode('expansion_factor')
->min(1.0)
->defaultValue(1.0)
->end()
->booleanNode('brackets')->defaultTrue()->end()
->booleanNode('parse_html')->defaultFalse()->end()
->arrayNode('localizable_html_attributes')
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
use Symfony\Component\String\LazyString;
use Symfony\Component\String\Slugger\SluggerInterface;
use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
use Symfony\Component\Translation\PseudoLocalizationTranslator;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
Expand Down Expand Up @@ -1218,6 +1219,19 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder

$translator->replaceArgument(4, $options);
}

if ($config['pseudo_localization']['enabled']) {
$options = $config['pseudo_localization'];
unset($options['enabled']);

$container
->register('translator.pseudo', PseudoLocalizationTranslator::class)
->setDecoratedService('translator', null, -1) // Lower priority than "translator.data_collector"
->setArguments([
new Reference('translator.pseudo.inner'),
$options,
]);
}
}

private function registerValidationConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $propertyInfoEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<xsd:element name="fallback" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="path" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="enabled-locale" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="pseudo_localization" type="pseudo_localization" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="fallback" type="xsd:string" />
Expand All @@ -178,6 +179,17 @@
<xsd:attribute name="cache-dir" type="xsd:string" />
</xsd:complexType>

<xsd:complexType name="pseudo_localization">
<xsd:sequence>
<xsd:element name="localizable_html_attribute" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="accents" type="xsd:boolean" />
<xsd:attribute name="expansion_factor" type="xsd:float" />
<xsd:attribute name="brackets" type="xsd:boolean" />
<xsd:attribute name="parse_html" type="xsd:boolean" />
</xsd:complexType>

<xsd:complexType name="validation">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="static-method" type="xsd:string" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ protected static function getBundleDefaultConfig()
'paths' => [],
'default_path' => '%kernel.project_dir%/translations',
'enabled_locales' => [],
'pseudo_localization' => [
'enabled' => false,
'accents' => true,
'expansion_factor' => 1.0,
'brackets' => true,
'parse_html' => false,
'localizable_html_attributes' => [],
],
],
'validation' => [
'enabled' => !class_exists(FullStack::class),
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Translation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

5.2.0
-----

* added `PseudoLocalizationTranslator`

5.1.0
-----

Expand Down
Loading