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.
Some modules have watchdog messages t()-ed, some have not. Since the whole interface of Drupal is translateable, what about leting all watchdog messages to be translated somehow? Watchdog types are already translated (when printed out and not when stored)...
The .pot extactor script should also be extended to recognize watchdog type names (first param to watchdog()), since they are also target for translation.
- The only problem is what translation to use in these cases on a multilingual site (ie. more then one locale set up in Drupal). The site default language should be used I guess. But then t() should be extended to use the site default langauge if a parameter says so. But then locale() needs that extra parameter, and then for users not having the default language set, two langauge caches would be loaded into memory, so it is not too performant...
- The second option is to let the watchdog messages be translated later on when displayed. But then dynamic contents would not be allowed, so we would need to have a new db field, containing the serialized dynamic data that should be applied to the t() call when messages are displayed. This brings us to the problem of storing translated data in the dynamic part (eg. "23 bytes" or "2 days before" are targets for translation).
- Or we could go on with not translating the watchdog() messages, but then this should be set as a rule, and all t()-ed watchdog messages should be "un"t()-ed. Drupal will not be as useable as it could be in this case, but we get rid of some of the ugly problems outlined above...
Comment | File | Size | Author |
---|---|---|---|
#11 | translatable-watchdog-strings-HEAD.patch | 18.24 KB | Stefan Nagtegaal |
#8 | t_watchdog_quoted.patch | 17.88 KB | Morbus Iff |
#2 | drupal_28 | 18.29 KB | Stefan Nagtegaal |
#1 | watchdog-translatable-strings-1-of-2.patch | 8.26 KB | Stefan Nagtegaal |
Comments
Comment #1
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedThis patch takes care for the following files:
I will continue sending patches, so we can finally close this task...
Still todo:
Comment #2
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedThis patch ovverrides the previous one... This patch fixes all untranslatable watchdog strings...
I would really like to see this hit CVS...
Comment #3
Dries CreditAttribution: Dries commentedI'm OK with the patch. Not sure what others have to say about it.
Comment #4
Gábor HojtsyThe only problem with t()-ing all watchdog messages is that the t() will be using the locale selected for the user when the watchdog logged event happens. That means that on multilanguage websites, the watchdog log will be multilingual. I don't see any other problem though.
Comment #5
(not verified) CreditAttribution: commentedThe patch doesn't seem to specifically address the first two bullets - the first bullet seems to address Goba's comment. However, from the standpoint of "what is Drupal doing now?", I think this patch is "ok", mainly because Drupal is /already/ t()ing some watchdog messages (just not everywhere), and no one brought these points up before. If anything, now that all watchdog entries have been t()'d, a second patch should be opened to address the locale issue.
Looking at the patch, there does seem to be a slight discrepancy concerning quotes and apostraphes to signify named content. I'm not sure if this is covered in any sort of "message style guide". The original code uses something like:
but the t()'d code forgoes the quotes around [title]. I personally prefer the double quotes. The same sorta thing shows up a few patch lines later with %site (the second instance of %site, even more lines later, /is/ quoted properly, however). Continuing on, the first change to blogapi.module flips the original single-quoted to double-quoted under watchdog (I prefer the double-quote).
Shall I provide a new patch file with my anal changes, standardizing quotes to double?
Comment #6
Morbus IffBah, #5 is me.
Comment #7
Dries CreditAttribution: Dries commentedStandardizing the quotes in messages is a good thing. An updated patch is welcomed.
Comment #8
Morbus IffI've taken the drupal_28 patch and tweaked the quotes. Attached.
Comment #9
Dries CreditAttribution: Dries commentedAt first glance, that patch does not appear to apply against HEAD.
Comment #10
Morbus IffDunno about drupal_28, but mine was just an editing of that file - I won't have time to create a proper patch from scratch/HEAD for awhile (still working on converting my existing site over).
Comment #11
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedNew patch against most recent CVS..
Please apply or comment on this what should be changed...
Comment #12
Dries CreditAttribution: Dries commentedCommitted to HEAD.
Comment #13
(not verified) CreditAttribution: commented