Right now the language select is placed "near the bottom" of the fields in the form. Reordering fields sometimes puts the select between other fields. Making the language select a pseudo field, implementing hook_field_extra_fields corrects this problem. The language can now be placed just like any other field, making it possible to place it into fieldsets (e.g. vertical tabs) too.
Attached is a simple patch that ads locale_field_extra_fields() support for the language select. I'm not quite sure if the condition to check when to add the language select to the extras array is sufficient. I took the same condition as the default locale_form_alter() uses.
Comment | File | Size | Author |
---|---|---|---|
#43 | node_module.1074672_43.patch | 2.97 KB | Schnitzel |
#42 | node-language-selector-1074672-41.patch | 2.54 KB | webflo |
#42 | node-language-selector-tests-only-1074672-41.patch | 1.71 KB | webflo |
#36 | node_module.1074672_36.patch | 845 bytes | boran |
#37 | node_module.1074672_37.patch | 846 bytes | boran |
Comments
Comment #1
plachThis sounds more like a feature request to me, although in D6 CCK provided the language pseudo field. So this could be considered an oversight while porting CCK in core. Let's hear what core maintainers have to say.
However:
The test should check if multilingual support is different from disabled otherwise we wouldn't have the language pseudo field for tanslatable nodes.
Powered by Dreditor.
Comment #2
plachComment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #4
plach@mikewink:
The current patch cannot be committed as is. Why did you ignore #1?
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedHi plach,
I'm a bit confused. Tell me what to do and I will work on the patch? I don't know what's the problem in #1? There is a check in the patch and the patch passed the tests.
Comment #6
plachThe problem is that the current patch checks if multilingual support for the node type is "Enabled", but this excludes all node types having multilingual support set to "Enabled, with translation" (and ony other contrib additional mode). If the line cited in #1 is changed to check if multilingual support is not disabled the language pseudo field will appear everywhere it needs to.
Comment #7
plachBugs are fixed in the development version first, backported then.
Comment #8
plachI actually think this should go into D7, otherwise every module dealing with content language (e.g. entity_translation and i18n_node) will have to provide its implementation.
Comment #9
claudiu.cristeaBecause of future #375397: Make Node module optional we need to fix this in the Node module rather than Locale module.
Comment #10
claudiu.cristeaHere's a patch against Node module.
Comment #11
claudiu.cristeaTypo fix in title.
Comment #12
plachAgreed. We also should consider #540294: Move node language settings from Locale to Node module. Cannot test this now, however:
The comment should wrap at column 80.
Shouldn't this be a "Node module element" too now?
24 days to next Drupal core point release.
Comment #13
claudiu.cristeaOK. Fixed your inputs from #12 , but postponing till #540294: Move node language settings from Locale to Node module. After #540294: Move node language settings from Locale to Node module is fixed, I will reroll the patch.
Comment #14
claudiu.cristeaForgot the patch :)
Comment #15
Gábor HojtsyLooks like a great suggestion for improvement.
Comment #16
Gábor HojtsyTagging for the content handling leg of D8MI.
Comment #17
Gábor Hojtsy#540294: Move node language settings from Locale to Node module landed.
Comment #18
claudiu.cristeaThe name of the node-type language variable has changed.
Comment #19
claudiu.cristeaHere's a patch to review.
Comment #20
Gábor HojtsyNode language is not dependent on locale in Drupal 8 anymore, it merely needs language.module.
Also, what is this giving us exactly? Placement in the form and display? Can add language to display? Will it be added automatically to the render output after this patch?
Comment #21
claudiu.cristeaThe title says all about this feature: Allow language select to be rearranged inside node form. It's only about the form. Many site builders need flexibility on placing the Language select. That's all.
See the screenshot.
Comment #22
Gábor HojtsyLooks good to me both on patch review and visually.
Comment #23
webchickWe just got under thresholds tonight, so features are back on the table.
This patch seems reasonable to me. This is technically a data structure change in D7, but one could argue it's also a bug that it doesn't do this already.
Committed and pushed to 8.x and 7.x. Thanks!
Comment #24
claudiu.cristea@webchick,
This patch cannot be applied to 7.x as it is... because:
I need to backport the patch first. Please revert the patch in 7.x because it will not work.
Comment #25
claudiu.cristeaMoving to 7.x too
Comment #26
webchickWhoopsie. :D
Reverted 7.x commit. Thanks for catching that!
Comment #27
webchickComment #28
Gábor Hojtsy@claudiu.cristea: the OP (first patch) looks like it would be a good start on a D7 backport?
Comment #29
claudiu.cristea@Gábor Hojtsy,
Yes, I will fix that in Locale module for D7 in order to keep the logic before #540294: Move node language settings from Locale to Node module. That patch is a good stating point. I will come with a patch later today.
Thanks.
Comment #30
Gábor HojtsyNot on the D8MI sprint anymore.
Comment #31
tim.plunkettRerolled.
Comment #32
tim.plunkettFixing tag.
Comment #33
hellolindsay CreditAttribution: hellolindsay commentedAny update on this? Seems there has been no new comments since May. I would very much like to be able to rearrange the language field in Drupal 7.
Comment #34
BrockBoland CreditAttribution: BrockBoland commentedNeeds issue summary
Comment #35
Gábor HojtsyI think this regressed somehow, I don't see this field on Drupal 8 anymore. :/ I think we might have forgotten to update the functionality somehow when we moved it from locale module(?).
Comment #36
boran CreditAttribution: boran commentedThe variable node_type_language_ TYPE was used to determine visibility of the language field on the field ordering list,
However the variable node_type_language_hidden_TYPE is used to determine visibility of the language field on the node/add form (see NodeFormController.php).
The same logic should be apple to both.
So change
if ($module_language_enabled && variable_get('node_type_language_' . $bundle->type, 0)) {
to
if ($module_language_enabled && !variable_get('node_type_language_hidden_' . $bundle->type, TRUE)) {
(joint analysis/fix by roderik & boran :-)
Comment #37
boran CreditAttribution: boran commentedOops, but in that last patch, new one attached, a "!" was missing.
(joint fix by roderik & boran)
Comment #38
pp CreditAttribution: pp commentedset it needs review
Comment #39
webflo CreditAttribution: webflo commentedThe patch looks good. Reviewed and tested it.
Comment #40
Désiré CreditAttribution: Désiré commentedstill needs tests, thanks for the review
Comment #41
Schnitzel CreditAttribution: Schnitzel commentedComment #42
webflo CreditAttribution: webflo commentedI wrote a small test for this. The second path should fail.
Comment #43
Schnitzel CreditAttribution: Schnitzel commentedas discussed with @webflo there is already a test for this: testNodeTypeInitialLanguageDefaults, but there is no test for the field rearranging, so added a new test for this.
Comment #44
Gábor HojtsyPatch looks good, adds tests to avoid this regressing again! Should be RTBC if/when it comes back green.
Comment #45
webflo CreditAttribution: webflo commentedYes, looks good!
Comment #46
webchickCommitted and pushed to 8.x. Thanks!
Moving to D7.
Comment #47
klonosThanx! I really can't wait for this to get in D7 too.
Comment #48
boran CreditAttribution: boran commentedJust a little note: in 8.x, the language field is not visible on the manage display tab for fields. (Above we are talking about the ordering in the edit tab)
On 7.x it is there, but has the default of visible (incovenient, needs to be hidden for any sites I do).
Now I dont see the need for it in the display tab, but perhaps there is a use case that I'm not aware of, where one might want to display the language on a node. If so, should a separate issue be raised?
(PS enjoyed dc munich indeed!)
Comment #49
Gábor Hojtsy@boran: indeed it not appearing on the manage display screen at all seems like (a separate) regression, that would need its own tests too. It only applies to Drupal 8. However, it sounds like an improvement that nodes would not have the language field displayed automatically anymore. Can you open an issue for this? Do you want to work on it? That would be great! :)
Comment #50
boran CreditAttribution: boran commented@gabor: ok, moved to #1757504: Regression: language field is not visible on manage display, I'll aim to do it some evening this week, be patient :-)
Comment #51
boran CreditAttribution: boran commented@webchick/#46:
D7 does not have this issue, the language field can be repositioned in Edit and Display tabs.
This was a D8 only (regression) bug.
Comment #52
Gábor Hojtsy@boran: I'm not seeing this working on Drupal 7. Also, it says above it was committed briefly and then removed (http://drupal.org/node/1074672#comment-5667904). Are you seeing the field on the manage fields tab on Drupal 7?
Comment #53
klonosIt most certainly ain't there.
Comment #54
Gábor HojtsyRight, so this still stands as a backport. In the meantime, we lost the display field counterpart which is handled at #1757504: Regression: language field is not visible on manage display. We added tests for the manage field page here, so we should not loose it again. Same thing should go for the display fields one.
Comment #55
boran CreditAttribution: boran commented51/52/53: Hmm, so this is not in D7 core..
Ah! but, it _is_ made available by the i18n module (I had tested on a few sites with that enabled).
see i18n/i18n.module i18n_language_field_extra()
So if this issue is back ported to core, it will need to be removed from i18n - is there much point in that? i18n will be used I imagine on D7 multilang sites.
Or am I missing something?
I also have a question on how to make the default "hidden" when one adds a field via _language_field_extra(): have not figured that out yet.
Comment #56
liquidcms CreditAttribution: liquidcms commentedcan someone do a summary of where this issue is at:
- i have core 7.15: not included there
- i have latest i18n -dev: not included there
- i looked at patch from #42 but it isn't even close to applying to the current node.module
i'll see if i can redo patch from #42 to fit with current node.module
Comment #57
boran CreditAttribution: boran commentedYou find i18n_language_field_extra() on http://drupalcode.org/project/i18n.git/blob/refs/heads/7.x-1.x:/i18n.module and also in stable release like 7.4
Comment #58
liquidcms CreditAttribution: liquidcms commentedperhaps i am missing the point of this? i have a node edit form, it has a language selector on it: http://screencast.com/t/bJiSbGmtiHm
i would like to be able to go to Manage Fields for this node type and move where that selector shows up.
i have the latest -dev of i18n. it has the code listed in #55.
the language "field" DOES NOT show in Manage Fields.
Comment #59
klonosI couldn't see it either with latest devs of both core and i18n and I thought I was missing something. Turns out I was... you need to have i18n_node enabled.
Comment #60
liquidcms CreditAttribution: liquidcms commentedi18n_node was enabled; doesn't help.
Comment #61
liquidcms CreditAttribution: liquidcms commentedahh.. got it.. the patch in #37 worked.
Comment #62
Gábor HojtsyI don't think we should expect multilingual Drupal 7 sites to have i18n_node module enabled, they might or might not need that functionality. The language field is already provided by locale module though in Drupal 7.
Comment #63
boran CreditAttribution: boran commentedI would have though that making such updates to D7 core, even for features not optimally covered by a contrib module, adds a significant risk to the (monthly) D7 upgrade process.
Comment #64
Gábor HojtsyRemoving from D8MI sprint, where we focus on D8 :)