On existing sites, it is not possible to add a new language and prepare the translation of all existing content before enabling the language.

Currently, if you want to add the translation, the language need to be enabled. This is really a big issue for existing sites, regarding to SEO.

There is already a variable called entity_translation_languages_enabled that is a starting point.

Note that this variable should be explained in the documentation and probably configurable in the UI (see the issue #2339495: English language appears in list even if it is disabled).

Comments

b-prod’s picture

Status: Active » Needs review
StatusFileSize
new2.13 KB

This patch permits such feature.

Status: Needs review » Needs work
b-prod’s picture

Status: Needs work » Needs review
StatusFileSize
new2.13 KB

Fixes the typo of the previous patch.

b-prod’s picture

This is a reroll of the patch in #3, that do not change the README file (automatic correction of the IDE).

EDIT: Sorry for the patch number, I looked on another issue I was working on to set the comment number :-(

Status: Needs review » Needs work
b-prod’s picture

Sorry, wrong issue, wrong project... I was definitively tired last days :-(

b-prod’s picture

Status: Needs work » Needs review
StatusFileSize
new3.02 KB

Take care of including the language.inc file when there is only 1 enabled language, but some disabled ones. In such cases, this files is not included by Drupal and we get a PHP fatal error when calling the missing function language_negotiation_get_switch_links().

stefanos.petrakis’s picture

Status: Needs review » Needs work

Thanks for the report. Picking this up since recently the entity_translation_languages_enabled variable was exposed to the Admin UI (see #1175170: Optionally enable disabled languages for entity translation.), which loosely relates to this issue.

This feature request is still quite far from covering the case mentioned in this issue IMO.

Even if editing would be possible - by using an idea like the one in the patch from #7 - viewing and previewing the content at hand is not going to be possible. That is because the needed language-aware routing will not be available for the disabled language(s).
In other words, even if one can edit content in a disabled language, it won't be visible since Drupal will not produce a URL for displaying it for a disabled language.

Here are a couple of questions:

+ Why not use the "Translation is published" checkbox in order to control whether a translation is published or not? This setting in combination with the "Language fallback" one can allow you to control whether the content of a WIP-translation is visible or not.
+ What are you SEO-specific concerns? Would be interesting to know a bit about this.

Setting this to needs work based on the missing view/preview functionality. Comments and ideas very welcome.

plach’s picture

In D8 we got the rid of the ability of disabling languages because that was not deemed as an effective way to allow for bulk translations, as we have existing staging/site preview solutions that are way more powerful and generic. However, if I’m not mistaken, ET has been allowing to edit disabled languages so far, so there may be lots of sites exploiting this ability so we can’t match the D8 behavior.

For that reason, I think it would probably make sense to ensure editing translations works properly also for disabled languages.

I guess we could try to make language negotiation work with disabled languages by implementing hook_language_negotiation_info_alter() and override negotiation callbacks, but I bet this would become tricky pretty quickly. All considered, I’d like to reduce complexity to the very minimum required to provide an acceptable behavior and not having view/preview available should be, given that we lived without it so far and this is not a primary use case. If people really need to check their translated content they can always use the edit form.

Here's a code review for #7:

+++ b/entity_translation.module
@@ -727,10 +727,39 @@ function entity_translation_admin_paths() {
+function entity_translation_admin_is_multilingual() {

I'd simply call this entity_translation_is_multilingual() and count how many languages are returned by entity_translation_languages() to avoid duplicating its logic.

stefanos.petrakis’s picture

Status: Needs work » Needs review
StatusFileSize
new7.15 KB
new7.14 KB

Thanks for the update on this one, helped me figure out that this patch actually covers the special case where there is only one enabled language. If there are more than one enabled language, the UI already allows editing content using disabled languages. So, this is true; the requested functionality is already working, i.e. translation of disabled languages is allowed. Therefore I agree that it should continue to be supported.

I rerolled the patch and added a few tests to test the count of languages returned by entity_translation_languages() as well as the outcome of entity_translation_is_multilingual(). I also noticed that the EntityTranslationTestCase::disableLanguage() method was not working as expected (seems it's not possible to uncheck and submit a checkbox via drupalPost()).

Status: Needs review » Needs work
stefanos.petrakis’s picture

Status: Needs work » Needs review
StatusFileSize
new7.39 KB
new8.5 KB

Rerolling this, tests were failing for a reason :-/

plach’s picture

Status: Needs review » Needs work

Nice work! I have only a few cosmetic remarks, otherwise I think we're good to go :)

  1. +++ b/entity_translation.module
    @@ -737,10 +737,18 @@ function entity_translation_admin_paths() {
    + * Return TRUE if entity_translation_languages() returns multiple languages.
    

    This is an implementation detail I'd leave out from the PHP doc. What about: "Returns TRUE if multiple languages are available for translation."?

    Also, we're missing the @return documentation.

  2. +++ b/tests/entity_translation.test
    @@ -137,19 +137,39 @@ class EntityTranslationTestCase extends DrupalWebTestCase {
    +   * Enable an installed language.
    

    Missing @param doc and the verb should use the third person singular ("Enables").

  3. +++ b/tests/entity_translation.test
    @@ -137,19 +137,39 @@ class EntityTranslationTestCase extends DrupalWebTestCase {
    +  function enableLanguage($langcode) {
    

    Here and below: I'd prefer to always add the method visibility modifier, even if it's redundant, as this prevents me from inadvertently mark something as public, when I simply forgot to mark it protected :)

    I know this policy is not currently applied consistently, it was a later addition to my toolbox ;)

  4. +++ b/tests/entity_translation.test
    @@ -137,19 +137,39 @@ class EntityTranslationTestCase extends DrupalWebTestCase {
    +   * Disable an installed language.
    

    Disables :)

  5. +++ b/tests/entity_translation.test
    @@ -137,19 +137,39 @@ class EntityTranslationTestCase extends DrupalWebTestCase {
    +    if ($this->assertTrue($language_is_installed, t('Language identified by the language code :langcode is installed.', array(':langcode' => $langcode)))) {
    

    Why :langcode and not @langcode or !langcode?

  6. +++ b/tests/entity_translation.test
    @@ -304,6 +324,60 @@ class EntityTranslationTranslationTestCase extends EntityTranslationTestCase {
    +    variable_del('entity_translation_languages_enabled');
    

    Mmh, weird that we have to do this, I thought we got a new installation for each test method.

  7. +++ b/tests/entity_translation.test
    @@ -304,6 +324,60 @@ class EntityTranslationTranslationTestCase extends EntityTranslationTestCase {
    +   * Test the output of entity_translation_languages().
    ...
    +   * Test the result of entity_translation_is_multilingual().
    

    Tests :)

stefanos.petrakis’s picture

Status: Needs work » Needs review
StatusFileSize
new5.84 KB
new8.08 KB

Rerolling (against the updated dev), thanks for the scrutiny! Especially regarding 6., absolutely correct, had to read the manuals again.

P.S.: I opened a task for cleaning up the entity_translation.test file. #2878191: Clean up entity_translation.test (standards, cosmetic)