Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently the value inside "access_denied_message" configuration variable is not translatable.
Comment | File | Size | Author |
---|---|---|---|
#4 | r4032login-config-translate-2816587-4.patch | 1.14 KB | mr.baileys |
#3 | r4032login-translate-error-message-2816587-2-D8.patch | 2.49 KB | cristiroma |
#2 | r4032login-translate-error-message-2816587-1-D8.patch | 1.35 KB | cristiroma |
Comments
Comment #2
cristiroma CreditAttribution: cristiroma at Eau de Web commentedAttaching a patch to fix the problem using StringTranslationTrait as recommended here: https://www.drupal.org/node/322729.
Edit: I'm not sure this is 100% correct, as the output of Xss::filterAdmin($message) might end-up different from $message and the system could not pick-up the actual string to match against translations. On the other hand I was wondering couldn't the string be sanitised during saving instead during display?
Comment #3
cristiroma CreditAttribution: cristiroma at Eau de Web commentedAttaching a patch to sanitise the input also during saving, this way the string is fixed then translated.
Comment #4
mr.baileysGood catch.
Filtering should almost always be done on output, see https://www.drupal.org/docs/7/security/writing-secure-code-0/why-does-dr...
The documentation you linked to seems to be for Drupal 7. In Drupal 8, configuration is translatable, and the 'access denied'-string is part of configuration, so should be translated using the "configuration translation" framework/module, rather than running the string through t().
Since the module adds its configuration fieldset to the system information form, hook_config_translation_info_alter() needs to be used to include the translatable settings when translating system.site_information_settings. After applying the patch attached here and enabling the config translation module, you can translate the 'access denied' text via /admin/config/system/site-information/translate.
Comment #5
nedjo@mr.baileys
Nice work. A couple of suggestions.
Needs one more space indentation.
From the the
hook_config_translation_info_alter()
documentation, it looks like best practice here might be to pull the specific setting into a new configuration file,r4032login.site.setting
.Comment #6
nedjoCancel that, I was overlooking the fact that all this module's configuration is added to that form.
Comment #8
Nixou CreditAttribution: Nixou at Actency commentedCommitted, thanks !