It would help DX (developer usability) to change token_replace() to support passing in langcodes in $message, rather than having to provide a full object. Unless we allow the simpler parameter we will continue to have modules do something like $message['language'] = (object) array('language' => $language); which is just wrong. Let's standardize on functions like t() and accept a 'langcode' option instead.
Issue highly inspired by #1305378: Tokens should use $options['langcode'] and not need a language object
Comment | File | Size | Author |
---|---|---|---|
#29 | 1305378-hook_mail-29.patch | 22.87 KB | Gábor Hojtsy |
#26 | 1305378-hook_mail-25-26.interdiff.txt | 1.63 KB | webflo |
#26 | 1305378-hook_mail-26.patch | 22.9 KB | webflo |
#25 | 1305378-hook_mail-25.patch | 22.31 KB | webflo |
#21 | 1305378-hook_mail-21.patch | 20.95 KB | savithac |
Comments
Comment #1
Gábor HojtsyRelated: #1754162: Implement language aware tokens for one time login link and cancel link
Comment #2
Gábor HojtsyShould also include a line of documentation, looks like hook_mail() does not document the language option in $message in any way in fact.
Comment #3
PrabhuG CreditAttribution: PrabhuG commentedworking on.
Comment #4
PrabhuG CreditAttribution: PrabhuG commentedintial patch
Comment #5
Gábor HojtsyComment #6
Gábor HojtsyThanks for the patch, let's clean it up!
langauge_default() should be good still AFAIS, don't see why did you change these.
$langcode is used just down there a little bit later.
language_default()->langcode should be it.
There is no $langcode_interface, should be $language_interface->langcode
Typo lancode => langcode.
Use language_default()->langcode.
Hm, as per Drupal code style, this should be:
if (!empty($langcode) {
$language = language_load($langcode);
}
That is, add space after if, wrap code in {}. Then I'm not sure if this is the right code, but not seeing the surroundings yet.
You also changed the argument here to $langcode in the invocation; should change in the function too.
Also, this token_replace will only apply once the token patch is committed from http://drupal.org/node/1305378
Should be language_default()->langcode;
Say Optional language code.
language_default()->langcode
Comment #7
PrabhuG CreditAttribution: PrabhuG commentedThe patch is cleaned up.
Comment #8
PrabhuG CreditAttribution: PrabhuG commentedComment #9
Gábor HojtsyLet's fix line wrapping here :)
Why are you not passing on just $options (leave it as-is)? It should already have a langcode properly as needed, right?
lancode typos still here.
I'm afraid you did not take the whitespace suggestions into account :) if should have a space right after, else should have a newline before and a space after.
No phpdoc to update above the function?
if should have a space after.
Comment #10
PrabhuG CreditAttribution: PrabhuG commentedpatch updated. I hope now all test will pass :)
Comment #11
Gábor HojtsyLine ends should not have whitespace.
Please, do use whitespace after commas. Please.
Like the third one :)
Language code to use to generate the e-mail text.
Variables is certainly not a callback function, its an array :)
This also sounds like is not the right documentation here.
Space after if, please, pretty please.
The new text now rans over 80 chars, just wrap to 80 chars, so the last word goes on a new line. Then "Optional" at the start can also be made "(optional)" like in other comments.
Comment #12
PrabhuG CreditAttribution: PrabhuG commentedcomments updated testing.
Comment #13
PrabhuG CreditAttribution: PrabhuG commentedcomment updated in function description.
Comment #14
PrabhuG CreditAttribution: PrabhuG commentedcomment updated in function description.
Comment #15
PrabhuG CreditAttribution: PrabhuG commentedcomment updated in function description as (optional)
Comment #16
PrabhuG CreditAttribution: PrabhuG commented#15: 1305378-hook_mail-14.patch queued for re-testing.
Comment #18
Gábor HojtsyPatch does not apply anymore due to other patches landing. Needs a reroll.
Comment #19
Gábor Hojtsy@PrabhuG: can you help reroll this patch?
Comment #20
PrabhuG CreditAttribution: PrabhuG commentedI'll be working on this weekend :)
Comment #21
savithac CreditAttribution: savithac commentedComment #23
Gábor HojtsyTagging for langcode conversions.
Comment #24
Gábor HojtsyWhy did this cause all these new failures? We need someone to closely follow core changes, with updates far in between, core changes way too much and this will never apply when a committer comes around. :/
Comment #25
webflo CreditAttribution: webflo commentedRerolled the patch from comment nr. 13.
Comment #26
webflo CreditAttribution: webflo commentedFixed the broken test in UserTokenReplaceTest.
Comment #27
Gábor HojtsyThanks for the reroll, looks good to me!
Comment #28
webchickThis all looks good, but no longer applies due to #1757566: Convert user account e-mail templates to configuration system. Could we get a quick re-roll?
Comment #29
Gábor HojtsyRerolled.
Comment #30
webchickGreat. Testbot back to green.
Committed and pushed to 8.x. Thanks!
This will need a change notice.
Comment #31
webchickI knew I forgot one of the 30 things we need to do when that happens. :P~
Comment #32
Gábor HojtsySubmitted http://drupal.org/node/1783392 and http://drupal.org/node/1783398
Comment #33
Gábor HojtsyUnfortunately this conversion was not 100% complete, looks like. @webchick noticed a bug with this, while building the Drupal 8 Spark disto. update_mail() is not yet converrted. Opened #1785966: Missing $language in update_mail() for that, let's fix that quickly :)
Comment #35
swentel CreditAttribution: swentel commentedSmall follow up over at #1889122: Notice: Use of undefined constant langcode - assumed 'langcode' in _update_message_text()
Comment #36
xjmUntagging. Please remove the "Needs change notification" tag when the change notice task is complete.