
As part of the D8 multilingual initiative, we want to add a langcode property to all entity types, just like we currently already have for nodes and comments.
This issue is a merging of prior work done in #1444966: Add langcode property in taxonomy schema, #1439680: Rename $user language property to langcode, and #1444992: Add langcode property in file schema to make it easier for reviewers and committers to track this in one patch. Committers: please credit the sprint participants from the prior issues, hairqles, kalman.hosszu, balagan, csg in addition to this issue's participants when committing this.
Patch summary:
- Adds a langcode field to {file_managed}. A hook_update_N() function sets existing files to LANGUAGE_NONE for reasons explained in the code comments. file_save() defaults $file->langcode to LANGUAGE_NONE. Tests included for the update hook and ability to file_save() with a desired langcode.
- Adds a langcode field to {taxonomy_vocabulary} and {taxonomy_term_data}. A hook_update_N() function sets existing vocabularies and terms to language_default()->langcode. taxonomy_vocabulary_save() and taxonomy_term_save() do not apply any default langcode, just as nodes and comments do not in their save functions. Patch adds explicit langcode in tests and install code that calls the save functions directly. taxonomy_form_vocabulary() and taxonomy_form_term() set a default of language_default()->langcode, with an @todo pointing to #258785: Provide more flexible settings for initial language on content types. There is no language selector UI on these forms yet, as per the issue summary on #1444966: Add langcode property in taxonomy schema. Tests are included for the upgrade path, but not for anything else, as per #1444966-18: Add langcode property in taxonomy schema.
- Splits {users}.language into 2 fields: langcode and preferred_langcode. Code added to locale module to make its one language selector control both properties, as per #1439680-37: Rename $user language property to langcode. Code comments added for instructing how a contrib module can override this synchronization. Tests included for the upgrade path and existing locale.test assertions expanded to cover both properties.
Comment | File | Size | Author |
---|---|---|---|
#17 | interdiff.txt | 2 KB | gábor hojtsy |
#17 | 1454538-17.patch | 35.38 KB | gábor hojtsy |
#12 | 1454538-12.patch | 34.86 KB | gábor hojtsy |
#8 | 1454538-8.patch | 34.85 KB | kalman.hosszu |
#5 | 1454538-5.patch | 34.86 KB | effulgentsia |
Comments
Comment #1
gábor hojtsyComment #2
effulgentsia CreditAttribution: effulgentsia commentedGabor, I think this captures everything we discussed from the other issues and in chat. Can you review and confirm?
Comment #3
effulgentsia CreditAttribution: effulgentsia commentedThis should be !isset(). This patch fixes that.
Comment #3.0
effulgentsia CreditAttribution: effulgentsia commentedUpdated issue summary.
Comment #3.1
effulgentsia CreditAttribution: effulgentsia commentedUpdated issue summary.
Comment #3.2
effulgentsia CreditAttribution: effulgentsia commentedUpdated issue summary.
Comment #5
effulgentsia CreditAttribution: effulgentsia commentedThe #3 errors were due to me adding an incorrect
'langcode' => LANGUAGE_NONE
where the Forum test submits a vocabulary edit form. As noted in the summary, this issue is not about adding a UI to the vocabulary and term forms: that will come in a follow-up, so this patch removes this erroneous change to forum.test.Comment #6
effulgentsia CreditAttribution: effulgentsia commentedComment #7
gábor hojtsyFirst of all, thanks for this fantastic patch! I spent considerable time with reviewing this patch today (and we discussed this in detail while you wrote it last Friday). All-in-all I think it looks very solid. The initialization for files and terms/vocabularies for upgraded sites looks good. The snippets to sync the user preferred/entity language by default look great. We can retain our simple UI while providing flexibility for those who want to separate preferred language from entity language. I only found very minor issues that I think @xjm would point out sooner or later :)
Summaries should start with 3rd person verbs now.
PS. also asked @fubhy and @tstoeckler to review this patch, hope they can get to it soon.
Leaving needs review since the issues are very minor.
Comment #8
kalman.hosszu CreditAttribution: kalman.hosszu commented3rd person verbs are fixed.
Comment #9
xjmRegarding the update hook docs:
#1414640: No documentation standard for hook_update_N() summaries [policy, no patch]
Comment #10
gábor hojtsy@xjm: In other words, its fine as it is now :)
Comment #11
fubhy CreditAttribution: fubhy commentedMaybe this is just nitpicking, but those two issues are the very last things that I noticed. Feel free to ignore them as they probably are irrelevant.
This should just read "modules" (not module's). Maybe even rephrase it to "... in case a module alters the weight of the other element."
This is a private function so it doesn't really matter but maybe we could use proper grammar like "Sets the value of the user register and profile forms' langcode element."
Other than that it looks nice and ready to go.
Comment #12
gábor hojtsyThose two text change suggestions are great IMHO, so here they are. Any other concerns?
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedThis looks good to me. I'm hoping that we can standardize some of this code soon into entity.module.
I think a lot of eyes have +1 this in addition to me so RTBC.
Comment #14
fastangel CreditAttribution: fastangel commentedI've tested and it works perfectly.
Comment #15
plachThis is indeed a great first step towards having language support enabled on any entity (the next logical step would be to factor out the language support logic/ui and move them to the base entity object/module). Just a couple of notes:
The related update functions nicely explain the reasons why they are defaulting to the (different) values above. Also these lines could use an explicit comment clarifying them.
This looks sensible to me, I'm just wondering what is supposed to happen in the case of the Entity translation module, which is the most likely candidate to mess with the entity
'langcode'
columns in D7 (see #1280546: Introduce a language selection widget for every entity). Since it is going to be moved to core in D8, who will be responsible to perform this update properly? I'd say needing to install an 8.x version of the ET module just to be able to upgrade would be nonsensical.26 days to next Drupal core point release.
Comment #16
gábor hojtsy@plach: re your first note, this is being addressed with #258785: Provide more flexible settings for initial language on content types and the code in question added by this patch is likely not there for longer than a month or two. Let's not ping-pong this with that given we want to move setting of defaults to a versatile UI.
Your second note did not have any consequences for the status of this patch. I think that question comes up when/if ET introduces a language property on entities. We can *then* add the same update code like we have for users except with a condition for whether a language field existed if we want to solve that in core. We usually don't have migration path for contrib modules in core, so the other alternative is for ET to have a D7 release which people should update to before updating to D8. That release would prepare the entity tables to have langcode like D8 expects, in which case we already have code in this patch to cover that situation.
Let's have this land and work towards flexible defaults in #258785: Provide more flexible settings for initial language on content types.
Comment #17
gábor hojtsyHere is the requested doc update anyway, since the patch needed a reroll due to another D8MI patch landing. It is just a doc change as per requested, should not change RTBC status.
Note once again that parts of this patch were worked on by MANY people and it was reviewed by *many* people earlier in previous issues at #1444966: Add langcode property in taxonomy schema, #1439680: Rename $user language property to langcode, #1444992: Add langcode property in file schema, so if this issue looks slim and unrealistic to work out a change of this scale, just add up the existing work from all of those issues.
Comment #18
dries CreditAttribution: dries commentedCommitted to 8.x. Great start for adding better language support to entities.
Comment #19
webchickThere was a collision with update numbers, but I just went in and fixed it. http://drupalcode.org/project/drupal.git/blobdiff/2d6dcdd509126c6ab86e0c...
Comment #20
gábor hojtsyFantastic! Thanks, removing sprint tag.
Now onto making language based data accessibility (fields/properties) much simpler at #1277776: Add generic field/property getters/setters (with optional language support) for entities.
Comment #21.0
(not verified) CreditAttribution: commentedUpdated issue summary.