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.
Spin-off from #605630: Comment language administration UI
We want to store the language a comment was entered in. That language does not need to be editable.
Comment | File | Size | Author |
---|---|---|---|
#16 | 605862_comment_lang.patch | 3.25 KB | andypost |
#13 | 605862_comment_lang.patch | 3.03 KB | andypost |
#11 | 605862_comment_lang.patch | 2.92 KB | andypost |
#9 | 605862_comment_lang.patch | 2.49 KB | andypost |
#6 | 605862_comment_lang-2.patch | 2.56 KB | peximo |
Comments
Comment #1
andypostTested with 2 languages and it works
Suppose therу should be follow-up after #533924: Allow different language types to be enabled separately to set language of the content not the interface language
Comment #2
Dries CreditAttribution: Dries commentedOn my personal blog, some people will post comments in Dutch although I have none of the i18n/locale stuff enabled. So, Dutch comments would be stored as English afaik. At some point, it might be nice to be able to correct that. It seems like that could happen a lot though -- it is not because the interface is in English, that the comments will be in English. Commenters are not trained/educated content editors so I'd expect there to be a lot of clean-up work needed to be done by moderators.
Comment #3
andypostThis patch just parents language from node->language
I think to solve this we need language-changer for comments in admin somewhere but this task is for contrib.
Default behavior should check node->language then fallback to interface language.
It's not good idea to give user ability to choose a language of the comment form any kind of visual control.
Comment #4
peximo CreditAttribution: peximo commentedIn #605630: Comment language administration UI sun say:
And I reply:
IMO if a user view a node that "appears" in one language (with translated fields) it's a good idea to set the comment language like the content language and not the node language.
EG. a node with nid 1 has node->language = en and a set of fields translated to italian. If i get /it/node/1 the content of the node (the fields) is showed in italian. So IMO the comments are italian too more easily than english.
Comment #5
andypostAnyway the $comment->language shell be assigned at comment_form() stage and not in comment_save() because comment_save() could be used in triggers\actions staff.
So in my patch I use $comment->language in both insert and update
Comment #6
peximo CreditAttribution: peximo commentedOk, with this we have $comment->language like in previous (andypost) patch and the content language instead of node->language.
Comment #7
sunIf we go this route, then we should use the global $language->language here, I guess, or not?
I'm on crack. Are you, too?
Comment #8
peximo CreditAttribution: peximo commentedI agree with sun. The last patch use $language->language.
Comment #9
andypostIf you trying to use global $language so it should be defined
Comment #10
plachComment #11
andypostNow with upgrade path
Comment #12
catchThis looks great.
I think we should evaluate whether we want to mass-update the comments table on update with the language of the node they were posted on, if that's already set. However that requires a lot of thought and might not be desirable. I tested the upgrade path and it worked fine, did a describe on comments to verify everything was in place.
We need an index on language - but we need to have a query using it first to see if it's nid, status, language or just language or whatever, so let's discuss that in a (critical) followup issue.
Comment #13
andypostThis is a patch with index, because we dont really know what kind of queries will be run I use nid+language for #605630: Comment language administration UI
Suppose we can add more indexes latter as follow-ups
Comment #14
sunI agree.
Comment #15
catchNeed to add the index in comment_schema() too.
Comment #16
andypostOh, changed schema
Comment #17
catchThat's it. Please wait for green from test bot before committing.
Comment #18
webchickI understand Dries's concerns at #2, but I'm not sure what we can do about this, really... at least in core. Short of presenting a language selector to the user to choose which language their comment is posted in, which strikes me as a UX nightmare to figure out.
On IRC catch pointed out two things:
1. A contrib module could also hook into google translation API or whatever for assigning languages once the storage property is there.
2. Comment module currently deletes all child comments without warning, even if flat comments, and lets users click any reply link they want. Posting in a different language is the least of our worries.
;)
I'm inclined to agree. This patch looks pretty straight-forward to me.
Committed to HEAD. Though Dries, if you feel strongly about this, obviously feel free to roll-back.