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.
Problem/Motivation
User should be able to translate the profile.
Proposed resolution
Make Profile entity translatable
Remaining tasks
Review and discussion.
User interface changes
User will be able translate the profile
API changes
Profile entity will have a revision data table as well to store the translation of the revision.
Data model changes
Profile entity will properly utilize the field data table.
Comment | File | Size | Author |
---|---|---|---|
#22 | remove_langcode_entity-2634230-22.patch | 1.25 KB | mglaman |
#17 | remove_langcode_entity-2634230-17.patch | 804 bytes | finne |
#13 | remove_langcode_entity-2634230-13.patch | 1.45 KB | mglaman |
#11 | remove_langcode_entity-2634230-11.patch | 1.74 KB | mglaman |
#9 | Sélection_118.png | 15.86 KB | steveoriol |
Comments
Comment #1
jibranHere is a WIP patch.
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedI explicitly removed translatability for two reasons:
1) Translating profiles doesn't make a lot of sense.
Your name, address, gender don't change between languages.
2) It would be very hard to provide decent UX.
Our entity translation UIs cover the admin use case, there's no UI designed to be used by the end-user in the non-admin theme.
Your patch provides no UI either, we'd need a translate tab, an edit form, the ability to view different translations... All for a very non-defined use case.
Your revisioning changes make sense, please provide another issue for that.
Comment #3
jibranI was working on https://github.com/bojanz/profile/pull/23 and I realized
EntityViewData
doesn't use field data table if entity is not translatable so I think about making profile translatable.After discussion on IRC @bojanz agrees to remove
profile_field_data
because it is only used for storing the translations. I'll create a follow up issue for that.Comment #4
jefuri CreditAttribution: jefuri as a volunteer commentedSorry to reopen this. But why is there a langcode in the entity if it is not translatable? I experience issues because of it because the entity takes the active language of the visitor into regard when rendering an entity with a different language. Resulting in fields not showing because the language does not match.
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedComment #6
mglamanUpdating. We can remove the leftover entity key.
Comment #8
mglamanComment #9
steveoriolHello,
After Updating drupal/profile (1.0.0-alpha5 => 1.0.0-alpha6)
I get this error...
and after
Comment #10
mglamanArgh, yeah. Forgot the need for an update hook.
Comment #11
mglamanHere is an upgrade patch to fix errors
Comment #12
jibranThis should be done using query.
All the code above this line should be in separate update hook.
Comment #13
mglamanThat last patch didn't work. Here is a different approach which just using direct SQL queries to set `langcode` to NULL so that the entity definition updater will delete the field. Does not use sandbox as we cannot load the profile and set to NULL.
Comment #14
mglamanI've run #13 against all of my Drupal Commerce test sites, and a local production version of a client's site. It seems to be working fine. The biggest issue is that the field original spec says
not null: TRUE
, so we have to alter schema.Comment #15
jibranI added new tests to the patch. I don't know those will pass or not but changes looks good to me. Thanks for the fixes.
Comment #16
czigor CreditAttribution: czigor at Centarro commentedI applied the patch and ran the updates successfully. I could still open my existing profiles for view and edit. The {profile} and {profile_revision} tables have no more langcode column. So it looks good to me.
Comment #17
finneI could not get it to work on my installation because the langcode field cannot be null.
Attached a patch that
- alters schema to allow null
- sets the field to null
- removes the field.
Using this version of profile.install I got my installation working again. Probably overlaps with the earlier patches - ymmv.
UPDATE: patch is almost identical to #13 - that should probably work too.
Comment #18
skyredwangafter updating to latest commerce and profile, site status shows "Profile: The Language field needs to be uninstalled.". Then, apply #13 patch, it fixed the problem.
Comment #19
czigor CreditAttribution: czigor at Centarro commented@finne
Which patch were you using? #13 already includes allowing NULL for langcode.Ah ok, just saw your update.
Comment #20
finne@czigor: It did not work when I updated Profile to the latest dev and did a drush entup. Then I created my own patch (#17) at about the same time as #13 was created. Got confused/did not check. They differ slightly in how they get their langcode definition when removing. But I think both work.
+1 on RTBC
Comment #21
agoradesign CreditAttribution: agoradesign commented@finne: does that mean, you can verify that it works also, when the langcode field was already removed? I only had a quick look at the patch and thought "hopefully this works, when the field is already gone", but haven't tried it
Comment #22
mglamanHere's an updated patch which combines #13 and #17. Mostly checks if field exists, and if storage definition exists.
Comment #23
finne@agoradesign: patch #22 has checks if the field exists, so that should work. I did not test it yet.
Comment #25
mglamanThanks, everyone. Committed the fix and tagging new alpha.
Comment #27
bairlangga CreditAttribution: bairlangga commentedHi All, sorry for being newbie and jumping questions, please bear with me.
I've tried the patch #22, #17, #13 and have the profile.install file patched accordingly by first deleting the file and run the git apply command. All no avail, the error still persists. All cache clearance and cron jobs had been done.
However I must inform you that I encountered this when adding new user in Distro Open Social, running profile-8.x-1.0-alpha7. But I reckon this is module related issue, not distro issue. CMIIW.
Comment #28
minorOffense CreditAttribution: minorOffense at Coldfront Labs Inc. commentedSorry I need to chime in here. Translatable user profiles makes sense in a lot of use cases. One specifically we have with a client right now is with their "Author" profile on the blog section. We store their name, department and a short bio about them (which individual users manage). These fields are displayed in english and french depending on the language of the site user.
Another example would be if you had a shipping profile where shipments needed to be sent to different locations depending on their language. You could have different instructions or shipment details (e.g. different attention field instructions).
Or if you had a "display email" field on your user profile. Some organizations have different domains for each language and you'd want to show the right domain email for the right language (e.g.
info@healthpartners.ca
vsinfo@partenairesante.ca
).Basically any site that requires information to be available in multiple languages would pretty much require user profiles to be translatable. And that's a big list of sites (e.g every canadian federal, provincial or municipal government site). It should work and translate like anything else in Drupal.
Comment #29
hexabinaerTo have the discussion in one place: I fully agree with minorOffense. Please have in mind that we're not only talking about translating from one language to another (bio, info about the author) but also translating from one alphabet to another. For the latter users should be able to transliterate their name, address e. g. from Arabic or Hebrew to Latin.
Furthermore, the UI should not be an excuse. We already have UI solutions for content translation ;-)
Deliberately not making profiles translatable feels odd to me in terms of international adaption and inclusion.
Acknowledging that this issue is closed and there is already an issue for this topic, I just wanted to add my arguments for the big picture. Sorry for the interruption.
https://www.drupal.org/project/profile/issues/2899744