Follow up for #1831530: Entity translation UI in core (part 2)
Problem/Motivation
have to edit each field to see if it has translation enabled (or if it's able to have translation enabled)
Proposed resolution
in ui on manage fields add a column to note which are translatable
Remaining tasks
- write exact steps to get to the screen (Done)
- screenshot (Done)
- mark up (and screenshot) proposed additional column (Done) See #10.
- post patch with code to that adds the column (Done) See ##1.
- ui review
- code review
- write tests See #14
User interface changes
this is a ui issue. see above.
API changes
no api changes anticipated
Comment | File | Size | Author |
---|---|---|---|
#51 | drupal-add_column_to_manage_fields_tab-1833104-51.patch | 20.66 KB | nagwani |
#51 | interdiff_45.txt | 9.24 KB | nagwani |
#51 | interdiff_failpatch.txt | 1.58 KB | nagwani |
#50 | drupal-add_column_to_manage_fields_tab-1833104-50-shouldfail.patch | 20.74 KB | nagwani |
#47 | drupal-add_column_to_manage_fields_tab-1833104-47.patch | 16.69 KB | nagwani |
Comments
Comment #1
yoroy CreditAttribution: yoroy commentedI'll trade you a machine name column :-)
Comment #2
tstoecklerRegarding #1, see #1831890: Don't show "Machine name" in entity listings (as there's also some pushback on trying to remove machine names from admin overviews).
Comment #3
nagwani CreditAttribution: nagwani commentedAdding steps as per point #1
Enable the Entity Translation module. To know more about how to us the entity translations, you can visit the help page [/admin/help/translation_entity]. You can reach help page by clicking on Help link next to the Entity Translation module on Extend page or by visting the help page.
To enable Entity translations for a content type Goto (Taking article content type as an example) -
1. Goto Structure->Content types (/admin/structure/types)
2. Click Edit against the name of the content type for which you want to enable tranlation (/admin/structure/types/manage/article)
3. At the end of the form open up Language settings. Under Translation, tick the checkbox Enable transation.
4. Click Save and translation should be enable for your content type. To confirm click on edit again and then on Manage fields tab (/admin/structure/types/manage/article/fields). You should see non-editable translation field available. See screenshot 1
5. Once you have enable the translation for the content type, you need to enable each field.
6. To enable for body field, click on edit next to body field (in manage fields tab).
7. Go to bottom of the form, expand global settings and tick checkbox under field translation. See screenshot 2. Click Save
You should now be all set with your content type.
Comment #4
nagwani CreditAttribution: nagwani commentedComment #5
nagwani CreditAttribution: nagwani commentedAssigning to self. Tentatively will add something here in a day or two
Comment #6
nagwani CreditAttribution: nagwani commentedI managed to implement this. Though there are still things to do, I would appreciate review comments
Comment #7
Gábor HojtsyThanks for the patch!
- I think it may be better to say "Translatable" and "Yes/No" as values. The "Translation" header sounds possibly misleading to me.
- The column should be before the Operations column.
- I'm not 100% sure this should be in translation_entity.module, because *theoretically* other modules could enable and implement field translation workflows, but in practice that is probably not going to happen, so it looks good where it is.
Concrete code feedback:
Maybe add an extra line of comment of what is going on, something like:
Adds translation column to field overview forms.
Not indented enough (add 2 spaces).
Indented too much (subctract 4 spaces).
Comment #8
YesCT CreditAttribution: YesCT commentedIt was really nice working with @nagwani in irc. Thanks a lot; it's great to have both the mock up and a patch to play with. :)
@nagwani and I talked about possible @nagwani's idea for fanciness like having an Enable It for rows were translation can be enabled or having an Enable Translation operation s column. But concluded that we should just do the status here and not get too fancy. Doing the fanciness would be related to #1810386: Create workflow to setup multilingual for entity types, bundles and fields and #1831608: Show or hide the "Make field translatable" checkbox on the add field form depending on translatability and would complicate this issue too much.
I'd like to see
Also, marking needs work because I remember from working on the translations tab overview in the main et-ui issue, that Drupal uses a pattern of having the operations be the last column for tables. So I suggest moving the translation column to be second to last.
Comment #9
nagwani CreditAttribution: nagwani commentedUpdated patch with review comments. - Updated comment below
Comment #10
nagwani CreditAttribution: nagwani commentedUpdated patch with review comments.
1. Changed title of the column from translation to Translatable
2. Changed data of the column to show "yes" if translation is enabled for the module. For fields not enabled, we don't show anything
3. Move the Translatable column to before operations column.
Comment #11
nagwani CreditAttribution: nagwani commentedAdding interdiff between patch #6 and #10
Comment #12
YesCT CreditAttribution: YesCT commentedThe addition of the comment is nice. But wrap it at 80 chars and add a blank line between the one liner and the additional information. There are some examples in http://drupal.org/coding-standards/docs
Add a comment here to explain that this is ordering the columns so that operations is last in the table because that is the normal pattern.
This needs to agree with coding standards. http://drupal.org/coding-standards/docs#inline
Add a space after // and make it grammatically correct sentence(s) with a period.
So something like:
Comment #13
YesCT CreditAttribution: YesCT commented@nagwani Nice work getting the interdiff posted.
what do you think we should do when none of the fields have translation enabled? Maybe hide the column?
Comment #13.0
YesCT CreditAttribution: YesCT commentedUpdated done tasks
Comment #14
YesCT CreditAttribution: YesCT commented@berdir mentioned in irc that the code should have tests.
Like:
Test that the column is there for entities with translation enabled.
Test that the column is NOT there when translation is disabled.
Test that a field with translation disabled has no value.
Test that a field with translation enabled has "Yes" value.
Comment #15
YesCT CreditAttribution: YesCT commentedDoes the "Yes" need some kind of additional tag on it for accessibility, like "yes translatable"?
Comment #16
nagwani CreditAttribution: nagwani commentedI would sugget to hide the column if the translation is not enabled on the edit content type form. If none of the fields are enabled, i think it would be good to show the translation column to show that it is enabled on the content type page, but not for fields. Does that make sense?
Comment #17
nagwani CreditAttribution: nagwani commentedCan you guide me through on writing these tests.
Comment #18
Gábor HojtsyI agree with #16, if the entity type has translation enabled but not any of the fields it would still make sense to show this information, so the user knows to enable something :) Not sure if the best representation of that state is the empty Translatable column.
(Also restoring tag).
Comment #19
nagwani CreditAttribution: nagwani commentedUpdated all review comments from #12
Comment #20
YesCT CreditAttribution: YesCT commented@nagwani when you post a patch, change the status to needs review to get the test bot to test it, and to signal to others that you want them to review your patch. I'll do that now.
You still need some pointers on how to write tests, right?
Comment #21
nagwani CreditAttribution: nagwani commentedYes @YesCT.
Comment #22
plachPerformed some minor adjustment. Setting to needs work since this still needs tests.
Missing t() call.
Usually the variable holding the value returned by field_info_field() is called $field.
The capitalized T here is misleading: it's not immediately clear we are dealing with a key.
Comment #23
YesCT CreditAttribution: YesCT commentedIn the Translatable column. I think Yes is meaning translation has been enabled on that field. I'd like to see n/a for rows where translation *cannot* be enabled. What do we put there for rows where translation could be enabled, but it is not yet? Maybe a "enable" link?
I think in the drop bottom, one of the actions there is enable translation. But i'd have to check.
I don't have experience with accessibility patterns, but I was recently helping to review #1796292: Use of undeclared variable : $original_title in core/modules/forum/forum.module on line 1232. And in there, this is used:
'1 new post<span class="element-invisible"> in topic %title</span>'
If that is the normal way. Perhaps here we can use that like:'Yes<span class="element-invisible">translation is enabled</span>'
and'n/a<span class="element-invisible">translation cannot be enabled</span>'
Or are tool tips the thing to do? to clarify what Yes, No/enable, and n/a mean?
Comment #24
nagwani CreditAttribution: nagwani commentedI would suggest tooltips, since we are short on real-estate and may be other modules might also want to extend and add their own fields? Let me know and I will patch it.
Comment #25
YesCT CreditAttribution: YesCT commented@nagwani with regards to how to write tests. http://drupal.org/node/1468170 is the docs page for "Contributor task: Write an automated test for a Drupal core bug" and that is where I would start. Also, we should look for similar code that tests things regarding a column existing. I think #1832778-42: Include translation operation in overviews for translatable entities might have some useful examples as it includes tests that are dealing with whether things exist in a table or not. (however, not there that I put the patch file first and then the tests, but it is better because of the test bot to put the tests only patch first and the whole patch second).
If someone else has another issue with tests that would be similar to what nagwani could use as a starting point, please post a link.
Comment #26
nagwani CreditAttribution: nagwani commentedThanks @YesCT. Going through the links and hopefully will update a patch soon.
Comment #27
Gábor Hojtsy@YesCT: The edit link already leads to a page where you can enable translatability (and edit all other properties displayed in the table). I'd not make the translation one special, all others are edited there, so the edit link should suffice. So those that do not have translation enabled could either say No or be empty. It might be easier to spot the Yes-es, if there are no No-s :) I don't know.
Comment #28
YesCT CreditAttribution: YesCT commentedYeah, lets try it with no No-s. :) That also solves the how do I enable translation problem... cause they click on edit. :)
Comment #29
YesCT CreditAttribution: YesCT commenteduhg. How does this effect accessibility? visually having no No-s make it easy to spot.. but I'm wondering about screen readers.
'<span class="element-invisible">translation is not enabled</span>'
? [edit: added in the code html to make the code show]Comment #30
swentel CreditAttribution: swentel commentedYou'll need to find another way to make sure you're looking at a Field API row, because there's also the '_add_existing_field' row (or whatever key, don't know it by heart right now) and extra fields that can be on this screen as well. Contrib can add here too (like field_group). I suggest looking at the
#row_type
which should be on $form['fields'][$field_name']['#row_type']. The value for a field instance will be 'field', all other rows get another value there.Additionally, you'll have to check the colspan's too if you're only adding the translation row in there - unless you always add no matter what, but even then you'll have to make sure the table doesn't break.
Use $field_name instead of $value to be consistent with core.
Comment #31
YesCT CreditAttribution: YesCT commented@ksenzee sent me this helpful link in irc: http://zufelt.ca/blog/drupal-7-two-new-system-classes-improve-accessibility so lets try it here. Unless.. screen readers repeat the column header when they read each cell. ... Maybe I should get a screen reader! :)
Comment #32
nagwani CreditAttribution: nagwani commentedUpdated patch to include the following -
1. Added code to check if the translation is enabled on entity bundle. If not we do not add the Translatable column from the Manage fields page
2. Added code to check if a field supports translation. If not we show "n/a"
3. Added invisible tags around text
Need some help in checking if a particular field supports translation. Currently I am trying to use the function field_is_translatable(), but this only check the same thing that we set on the edit field tab. So I guess this is incorrect. What we want to achieve here is to put in a check to see if a fields supports translations, if yes and translations are not enabled, we show "blank column", if enabled we show "Yes" and not supported we show "n/a".
Another workaround could be that we use the $form['#extras'] as non translatable based on the assumption that "properties" are not translatable. and all fields are. Any pointers?
Screenshot of Changes done...
Comment #33
nagwani CreditAttribution: nagwani commentedFixed code review errors.
Comment #34
nagwani CreditAttribution: nagwani commentedAnd another stab at the coding standards....Phew, having a bad day today!!!
Comment #35
nagwani CreditAttribution: nagwani commentedCurrently working on fixing comment http://drupal.org/node/1833104#comment-6756420
Also fixing
1. Manage Comments tab
2. Manage fields tab on vocab
Comment #36
YesCT CreditAttribution: YesCT commentedI was helping in irc with this.
I dont think there is anything to "fix" about comments tab, vocab fields tab, or the configuration user account tab. Just need to get a screen shot of them, with some translatable fields added with translation enabled, and translatable field added but translation disabled.
Here is an example.
I did get an error:
Notice: Undefined index: widget_type in Drupal\field_ui\FieldOverview->validateAddExisting() (line 508 of core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php).
when adding a field to a vocab, but that could be unrelated. Will have to check.we came up with a comment here that is not translation specific... it fits on one line too:
should be "column if translation"
change "of" to "if"
Comment #37
YesCT CreditAttribution: YesCT commentedhere is a look at the invisible words for n/a, Yes and blank (No).
Comment #38
nagwani CreditAttribution: nagwani commentedFixed
1. Review comment from comment http://drupal.org/node/1833104#comment-6756420
2. Manage comments tab. To test you will need to enable translation first
3. Manage fields tab on vocab. To test you will need to enable translation first
Comment #39
nagwani CreditAttribution: nagwani commentedChanging to needs review to trigger tests.
Comment #40
nagwani CreditAttribution: nagwani commentedAdding tags again
Comment #41
swentel CreditAttribution: swentel commentednagwani : nice! Only one left over piece of code that can go away:
This can go away.
Comment #42
nagwani CreditAttribution: nagwani commentedUpdated patch including tests for content type, comment, vocabulary, user. Fixed comment # http://drupal.org/node/1833104#comment-6770520
Currently the tests that are pending are the ones to check for the field not being displayed if translation is disabled on entity level.
Screenshots for all pages attached.
Comment #43
nagwani CreditAttribution: nagwani commentedUpdated patch. Fixed a bug where in it was showing Translatable Yes even when it was not.
Comment #44
YesCT CreditAttribution: YesCT commentedI wonder if we can write the test for Entity and then extend it, passing in the arg for ... the url of the page to look for the column on, or maybe that is an arg to the entity somewhere?
Also, lets add tests for n/a on a n/a, Yes on a translate enabled, and no on a enableable but not translatable.
And then make a tests only.
and a version of the fix that fixes it wrong. uses Foo for Yes, Foo for n/a, Foo in the blank for no and see that we get 3 fails.. of course have to write the 3 tests for Yes, n/a, and blank. Those tests would have caught the problem with #43 :)
Comment #45
nagwani CreditAttribution: nagwani commentedAdded tests for n/a, Yes, not enabled.
Comment #46
nagwani CreditAttribution: nagwani commentedAdded tests for n/a, Yes, not enabled.
Comment #47
nagwani CreditAttribution: nagwani commentedFail tests. These are suppose to fail
Comment #48
nagwani CreditAttribution: nagwani commentedChange status to trigger tests.
Comment #49
YesCT CreditAttribution: YesCT commentedDont want to confuse this with the other test that just tests for the column showing. This one is for the value in the row.
This is for a field with translation enabled.
* Tests 'Yes' in Translatable column on comment manage fields tab for a translatable field.
or
* Tests value column on comment manage fields tab for a translatable field.
(might be longer than 80 chars and need shortening)
Check the other function summaries and make sure they are clear.
Dont want to confuse this with the other test that just tests for the column showing. This one is for the value in the row.
This is for a field with translation enabled.
* Tests 'Yes' in Translatable column on comment manage fields tab for a translatable field.
(might be longer than 80 chars and need shortening)
Check the other function summaries and make sure they are clear.
I think we still need a test for n/a ?
[this is just a quick look.]
Comment #50
nagwani CreditAttribution: nagwani commentedFail patch.
Comment #51
nagwani CreditAttribution: nagwani commentedFixed review comments from comment #49. Added check for n/a fields.
Setting to needs review to trigger tests
Comment #52
xjmGreat work on this so far! I have a few suggestions for organizing the tests, which I discussed with @nagwani and @YesCT in IRC.
Rather than adding additional modules that will be installed in all these tests, I'd suggest adding the methods to a new class, perhaps (e.g.) CommentTranslationFieldUITest. However, I need to check what's in EntityTranslationUITest. Any test methods on that class will also be run for the child class, so it's either misnamed, or intended to repeat certain tests for all the classes that extend it.
Each test method installs a new copy of Drupal, so it would be a good idea to merge these where possible rather than having a separate method for every GET request. (It's a matter of balancing manageable tests with performance, of course.)
Since this is repeated in every method, I'd suggest moving the creation of this user to a setUp() method.
The one-line summary should generally have a blank line between it and any subsequent paragraphs. (However, in this case, we probably want to move some of this text to inline comments.
Comment #53
xjmI looked in
EntityTranslationTest
and it has several of its own test methods, none of which use any entity-related protected test class member properties that I could see. Unless there is a specific reason to run these test methods five or six times, other test classes should not be extending this class. (This was not introduced with this patch, but is potentially a bug we should keep in mind when adding new tests.) Edit: I'll double-check this when I'm less asleep and file a related issue if appropriate.Comment #54
Gábor Hojtsy@xjm: this issue deals with tests extending *EntityTranslationUITest* not *EntityTranslationTest*. The UI test only has one test common method (testTranslationUI()) and is heavily dependent on the entity type being tested. I think this might be a misunderstanding :)
Comment #55
klonos...slightly better issue title. Thanx for working on this guys.
Comment #56
nagwani CreditAttribution: nagwani commentedWill post updated test patch soon. Have been out for some time now.
Comment #57
YesCT CreditAttribution: YesCT commented#51: drupal-add_column_to_manage_fields_tab-1833104-51.patch queued for re-testing.
Comment #59
Bojhan CreditAttribution: Bojhan commentedThis feels like a pretty bad idea. I mean, the form is already super crowded - its not a "linked" setting and we don't do this for other settings in fields They are all trown under instance/widget settings - why is multilingual different? I don't see this working on anything but really wide screens.
Comment #60
klonos99% of the sites I've built are multilingual. Most of these in two languages and quite a few in three. One of the repeated tasks I go through each time in order to ensure a content type is fully translatable is to check each and every field's multilingual settings. This leads to an endless back 'n' forth that is really tedious and nerve-breaking. As I add and rearrange fields to content types I need to go back and check their translatability. So, I either need to memorize the fields that are already translatable or to take notes as I do things. A total waste of time now that I know that this addition discussed here has a chance of being implemented.
I hope this answers the "why is multilingual different?" question. As for the "I don't see this working on anything but really wide screens." comment, let me kindly point you to Responsive table classes for modules and themes. So, thanx to #1276908: Administrative tables are too wide for smaller screens we can wrap the "TRANSLATABLE" column to a RESPONSIVE_PRIORITY_MEDIUM or a RESPONSIVE_PRIORITY_LOW class that will take care of hiding it when the table is displayed in smaller screens. No reason to not implement this then I guess.
Comment #61
Gábor HojtsyKlonos: the patch at #1810386: Create workflow to setup multilingual for entity types, bundles and fields has a much better overview, even across all entity types.
Comment #62
Gábor HojtsySo overall looks like the work here will not have a good chance to get in, however users will get an even better (and actionable) overview in #1810386: Create workflow to setup multilingual for entity types, bundles and fields where they get a UI that they can even use to make changes. So this looks like a duplicate of that one.
@nagwani: I hope you are not discouraged, you did a great job getting this patch through several reviews and improvements. It just turns out there is going to be a better solution. If you want to take on a simpler one for a break, #1869328: Restore simplicity of language list still has a task to resolve weights of items not shown once the list is saved.
Comment #62.0
Gábor HojtsyUpdated issue summary remaining tasks that were done, linked to issue comment number