Symfony 5.2 will be released in November 2020. This is the first article of the series that shows the most important new features introduced by this Symfony version.
The following pictures show the interface of a popular Internet service. The first image is the original interface in English and the second one is what you see when switching the application language to Spanish:
These kind of errors are very common, because different languages can be longer or shorter than the original application language. Another common issue is to only check if the application works when using basic accented letters, instead of checking for more complex characters such as the ones found in Polish, Czech, etc.
These problems can be solved with pseudolocalization, a software testing method used for testing internationalization. In this method, instead of translating the text of the software into a foreign language, the textual elements of an application are replaced with an altered version of the original language.
Account Settings is translated as
[!!! Àççôûñţ Šéţţîñĝš !!!].
First, the original text is expanded in length with characters like
to test the application when using languages more verbose than the original one.
This solves the first problem.
In addition, the original characters are replaced by similar but accented characters. This makes the text highly readable, while allowing to test the application with all kinds of accented and special characters. This solves the second problem.
In Symfony 5.2 we’ve added full support for pseudolocalization to help you debug internationalization issues in your applications. You can enable and configure it in the translator configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# config/packages/translator.yaml framework: translator: # ... pseudo_localization: # replace characters by their accented version accents: true # wrap strings with brackets brackets: true # controls how many extra characters are added to make text longer expansion_factor: 1.4 # maintain the original HTML tags of the translated contents parse_html: true # also translate the contents of HTML attributes (e.g. 'title') localizable_html_attributes: true
That’s all. The application will now start displaying those strange, but readable, contents to help you internationalize it. See for example the difference in the Symfony Demo application. This is the original page:
And this is the same page with pseudolocalization enabled:
What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...