When retrieving variables that are strings that should be translated, you are not translating them. I was always under the impression that this is necessary, otherwise that default value cannot be translated.
variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.')
Should be:
variable_get('extlink_alert_text', t('This link will take you to an external web site. We are not responsible for their content.'))
This occurs in both hook_init() and extlink_admin_settings().
As always, thanks for the great work.
Comments
Comment #1
quicksketchYou do not translate values that can be set by administrators. If we used t() for the default (which is cached) then the language returned would not be based on the user's language, but whatever language the cache was set in. If you want to translate variables, you can use the i18n package to set a value for each language.
Comment #2
quicksketchAh, nope looks like I'm incorrect. At least the default e-mail texts are translated as you say in Drupal core.
http://api.lullabot.com/system_site_maintenance_settings
Though interestingly it seems that user.module does some special tricks to avoid the caching problem I described:
http://api.lullabot.com/_user_mail_text
So it looks like the appropriate fix would be to make a special variable retrieval for translated strings. Something sort of like this:
This way the translated string doesn't get cached and will be retrieved in a way that matches the user's current language.
Comment #3
zzolo commentedThis seems like a bad hack, but I guess it is a fair approach given the Drupal variable system.
You should do a check for NULL, as someone could actually specify a blank string.
Comment #4
quicksketchGood point there. How does this patch look?
Comment #5
zzolo commentedExcellent!
Comment #6
quicksketchGreat, committed #4.