Closed (fixed)
Project:
Drupal core
Component:
user.module
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
31 Jan 2004 at 18:10 UTC
Updated:
22 Feb 2004 at 19:20 UTC
Here is a patch that does the following:
- Modifies _user_mail_text() to automatically override the default
strings when needed and apply t() on the strings. This lets Drupal translators
include default messages in translations, and also removes a lot of repeated code.
Modified the internal $messageid of the approval message from
welcome_approval_body/subject to approval_body/subject, so automatic variable
name computation can be done. This does not affect any variable table keys, since
the change was especially done to keep the variable names...
- Adds %login_uri and %edit_uri to move away from the concatenation approach used in
the default messages, thus making those messages visible for the .po extractor
- Uses direct return in help text generation when no more action need to be taken
on the help string (the '$output .=' approach was just plain silly looking and
misleading, since there was no preceding or appended string in $output)
A strongly suggested change :)
| Comment | File | Size | Author |
|---|---|---|---|
| Drupal-user-module-t-improvements.patch | 25.77 KB | gábor hojtsy |
Comments
Comment #1
gábor hojtsyBTW I have tested user.module with this patch applied, and it seems to work fine.
Comment #2
dries commentedIs this the suggested way to deal with translating user input?
While this patch addresses a number of user module issues I'm not fond of the approach taken ... Let us take a moment to look at the bigger problem by generalizing this case. In the past people have asked if they could translate the site slogan, the various submission guidelines, taxonomy terms, and much more. Point is that virtually all configuration strings should be translatable. With that in mind, I can't help but think that the suggested approach is nothing more than a user module specific hack.
I would like to think this through a little. Maybe we should look into extending the locale module such that (i) it can handle multiple input languages (and thus have defaults in multiple languages) instead of being limited to English and such that (ii) it can deal with translating dynamic, user-contributed data? We could start with administrator- or configuration-specific data and later extend it to user-contributed data such as, most notably, node titles and node bodies.
Comment #3
gábor hojtsyNope. This patch allows translators to translate the default strings provided for email sending in user.module. This patch does not modify the current Drupal behaviour in that it treats 'user input' (admin settings actually) as already translated regardless of what interface language is used. In this spirit, this patch does not modify anything in concept, or on the user interface, or anywhere, it just applies the changes needed for .po extraction and simplifies the code in user.module on the way. My priorities with this patch were:
default strings right away
The patch achives this goal. It might not be general enough, but the goal was far from translating user input, that is a lot more work to do. Currently we are focusing on the efforts of bringing the .po approach to locale.module, which is still a lot work to done. This patch (or a slightly modified version) is required to step further and kill a lot of .po extraction errors.
That said I don't think that this is a user.module hack, since even if we generalize this 'Drupal built in default' or 'translated default' or 'site specific admin setting' selection, we will not get too far from the approach I have taken in this patch (as far as I see at least :)) We could add something like the following to common.inc for example:
This would let any module to provide default setting strings, with defining a _setting_text hook, which provides the (translated) Drupal default strings as needed, but site specific admin settings would always override the (translated) factory defaults. That would change _user_mail_text() and its invocation the following way:
This would also unifiy all site specific admin settings having default text to have a 'site_' prefix (or any prefix, or no prefix if you desire).
Once again, I think that this situation is very different from what you are talking about Dries, since this is related to admin settings having defaults (and possibly translations) already known when Drupal is deployed, and with final values stored in the variables table if set. This is very much different then having slogans in multiple languages or even nodes in multiple languages. I really would like to see this patch (or a bit more generalized patch - as described above) included in Drupal before the freeze, so we can ship much better translations.
Comment #4
gábor hojtsyBTW, the 'Anonymous' user name was the first pioneer to start this kind of hacking, since it allows translators to provide a translation, and admins to override that with their own setting. So it might be the next candidate to integrate into this setting translation system (also in user.module).
Comment #5
gábor hojtsyAdditionaly to the 'Anonymous' name translation issue, another t() problem involving the 'statistics_userpage_link' setting could be solved with the generalized approach I have described here :)
Comment #6
dries commentedCommitted to HEAD.
Comment #7
(not verified) commented