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.
Disabled languages should not be available for entity translation (by default).
In some cases it might be useful being able to translate content to disabled languages before enabling it, thus it makes sense to have an option to turn that behavior on.
This is related to a todo I saw in entity_translation_overview
in entity_translation.admin.inc
line 93
.
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff-1175170-10-12.txt | 2.43 KB | hgoto |
#12 | entity_translation-add_ui_to_switch_disabled_language_availability-1175170-12.patch | 2.86 KB | hgoto |
| |||
#10 | 1175170-10.png | 94.77 KB | hgoto |
Comments
Comment #1
Pisco CreditAttribution: Pisco commentedThis patch disables disabled languages for translation by default, and adds a checkbox to
/admin/config/regional/entity_translation
to change that behavior.Comment #2
das-peter CreditAttribution: das-peter commentedJust applied the patch - works like a charm. Thanks.
Comment #3
plachThanks for the patch, actually my plan was to inherit i18n settings where possible.
Comment #4
joelpittetYes, only enabled languages makes sense in my case, hopefully there is not too many edge cases where this is needed?
Comment #5
joelpittetOh, I just noticed you have a nice little hidden gem in the latest dev:)
variable_get('entity_translation_languages_enabled', FALSE)
Thank you @plach!
Comment #6
hgoto CreditAttribution: hgoto at Studio Umi commentedThis is a little an old issue but I'd like to go ahead on this.
as joelpittet told, the function to toggle the availability of disabled language already exists. So adding a form field in the setting page is enough, maybe. Here is a simple patch for that.
(Disabled language is included by default and it may be better to revise the issue title...)
Comment #8
stefanos.petrakis@gmail.comThanks for this @hgoto, tests are now clean.
The FAPI element addition is perfectly fine as provided in the patch. There is one condition though that should be taken into account, and this has to do with the @todo comment in the first if block:
In case
i18n_node
is enabledentity_translation_languages_enabled
will be ignored. In that case, I would hide the FAPI element as well, to avoid confusion.N.B.1: This @todo is what started the whole issue, but implementing the i18n settings inheritance should be handled in a different issue.
N.B.2: We should think about having some tests for this, no matter how trivial the functionality, would be great to have them in the patch.
Comment #9
stefanos.petrakis@gmail.com@hgoto: Short update:
Comment #10
hgoto CreditAttribution: hgoto as a volunteer commented@stefanos.petrakis, thank you for your review and updates.
I see. I agree with you that it's better to avoid confusion. How about disabling the field keeping it visible? It may be nicer for easier understanding. Please see the attached image (took after the patch is applied).
Thank you! I adjusted the test proposed in #2339495: English language appears in list even if it is disabled and merged into this patch.
Comment #11
stefanos.petrakis@gmail.comThanks @hgoto, good stuff! We are close:
Missing a full stop at the end of this line.
After reading this code some, I am not sure we need to check for 'en' and 'es' at all, enabled languages will always be part of the list. And the function's name hints to testing disabled languages only.
Additionally, I would change the wording of the messages slightly, how about:
My previous comment about conditionally hiding this has a flaw. Looking at the code,
entity_translation_languages()
gets called in various places, so, even ifi18n_node
is enabled, this setting still makes sense e.g. for entities that are not nodes. So, on second thought, I would leave this FAPI element always visible and simply add a note along the lines of what you wrote. Here is a little draft/example:Thanks!
Comment #12
hgoto CreditAttribution: hgoto as a volunteer commented@stefanos.petrakis thanks! I agree with you on all the points you mentioned. I revised the patch.
In addition, I added the type
string
in the doc comment in the added method.Comment #13
stefanos.petrakis@gmail.comCommitted, thanks!
Comment #16
hgoto CreditAttribution: hgoto as a volunteer commentedGreat. Thank you!