This is not good. Specific to Basic Page node type, you cannot translate titles apparently. To reproduce:

a) Install with Standard install profile.

b) Turn on Content Translation module and its dependencies, like Language.

c) Add French and Spanish languages (or whatever language you want)

d) Go to admin/config/regional/content-language

e) Turn on "Content" as having custom settings, and enable translation for Basic Page content type. Make sure both Title and Body are checked as translatable.

f) Add a Basic Page node in English.

g) Try to translate it. You will see "Title (all languages)" on the title field, and if you save a translation, the new title will spill over into your English node.

Note: See comments #4, #5, and #7 for clarification. The problem is actually that the UI for setting up content language settings does not currently match the actual configuration. Field settings for translatable and not translatable are not currently on a per-bundle basis, although the UI shows them that way. So if you have one translatable and one non-translatable bundle (content type), the individual field translation might or might not work, depending on whether the shared title and body and other fields end up being set as "translatable" or not globally. This is being addressed on related issue #2143291: Clarify handling of field translatability

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

Issue tags: +Needs tests, +D8MI

I confirm this bug.

We should look at our test coverage.

jhodgdon’s picture

Priority: Major » Critical

xjm thinks this should be a "Critical".

jhodgdon’s picture

Priority: Critical » Major

I just tested this with a new content type that I added in the UI. Translation of title works there.

Interestingly, once I set this up, the Basic Page content type also started having a translatable title. So... not sure what was going on here. I guess I should start over with a new install and try again.

jhodgdon’s picture

Title: Cannot translate title of Basic Page node » Cannot translate title of Basic Page node if other content types are not translatable
Priority: Major » Critical
FileSize
39.71 KB

So... Even though YesCT had already confirmed this issue, I decided to start over with a clean new install of Drupal 8 on the latest git pull to test this. I followed the steps in the issue summary exactly (standard profile install in English, then add Content Translation & Language modules, add Spanish language, and set up Basic Page as translatable with Title and Body fields translated).

After saving the page at admin/config/regional/content-language, I note that it does show that both Title and Body are translatable for Basic Page. I also went to my config directory, and found in content_translation.settings.yml:

node:
  article:
    content_translation:
      enabled: 0
      fields:
        title: false
        body: false
        comment: false
        field_image: false
        field_tags: false
  page:
    content_translation:
      enabled: true
      fields:
        title: true
        body: true

So that looks correct.

But I can confirm that after adding a Basic Page node called "Food in Paris", clicking Translate, and clicking Add next to Spanish, I see the following:
Add translation - title is for all languages

So re-confirmed.

Then I add a new content type called "test". Go back to adding a translation of my first Page node, same as above screen shot. Still confirmed.

Now I go to the Content Language config screen and turn on translation for Article, with Title and Body translated. Looked at the config file:

node:
  article:
    content_translation:
      enabled: true
      fields:
        title: true
        body: true
        comment: false
        field_image: false
        field_tags: false
  page:
    content_translation:
      enabled: true
      fields:
        title: true
        body: true
  test:
    content_translation:
      enabled: 0
      fields:
        body: false

So that still looks right. But when I go to the Translate tab for my Page node, now it says "No translatable fields". ?!? Article says the same, after creating an English article. ?!? That isn't good.

Huh. Clear the cache, just in case (in the UI from the Perfomance page)... nope, no change there.

So now I go back to the content language settings page and turn on translation for my "test" content type (title and body as usual, and the config file looks right as usual). Now everything is working fine.

Go back to the content language settings page and turn off translation for Article and Test, and again I get "no translatable fields" when I try to translate my Page.

So it seems to be a problem of having some node types translatable and others not translatable. I think this warrants going back to "Critical" after all.

jhodgdon’s picture

As a note, I looked in my config "active" directory to see what was changing as I visited the language config screens.

I noticed that field.field.node.body.yml is being updated. After setting some of the node types to not translatable at the end of my testing in comment #4, it looks like this:

id: node.body
uuid: bd4286f0-b65c-4b76-a662-983db1c36f1d
status: true
langcode: en
name: body
entity_type: node
type: text_with_summary
settings:
  translation_sync: ''
module: text
locked: false
cardinality: 1
translatable: false
indexes: {  }

Note that line one from the bottom: translatable: false. It doesn't seem like this should be part of the field config??!? That is most likely part of the problem here, but I'm still not sure about the title non-translatability, because now I cannot even translate the body either, and if I make the other content types translatable, my titles on Page are also translatable.

jhodgdon’s picture

Oh, and just for kicks, one more test:

I made all content types translatable, but turned off Title for Article and Test. Now Body of Page is translatable, but Title is not.

Berdir’s picture

Yes, I noticed this too.

The problem is in content_translation_entity_field_info_alter().

That merges the settings of all bundles together with array_merge(), which means that the first bundle always sets the keys to FALSE and the following ones don't override it.

So far, so obvious.

The problem is that the UI is a big fat lie :)

There is no by-bundle configuration for this. For configurable fields, this information is on the Field and not the instance and for base fields, it would be possible but then we need to clone the field definitions by bundle, which is a bit ugly as we duplicate the memory usage and load-from-cache overhead for those.

See also #2143291: Clarify handling of field translatability.

catch’s picture

Should this be a duplicate and we bump the other issue to critical?

Berdir’s picture

Assigned: Unassigned » plach

I'm not sure honestly, maybe :) The other is more a task, but refactoring that might fix this bug, so maybe it's better to keep this open?

Assigning to @plach for his opinion...

jhodgdon’s picture

They seem like pretty much the same issue to me. +1 on upping the priority of that one to "critical" and editing its issue summary so that it includes making sure the UI makes sense after the behind-scenes refactoring is done. Or this issue could be kept open for the UI. Either way, I think #2143291: Clarify handling of field translatability should be critical.

plach’s picture

Status: Active » Postponed

Promoted #2143291: Clarify handling of field translatability to critical, postponing this on it.

plach’s picture

Issue tags: +language-content
Greg Sims’s picture

At the alpha10 level of code I created a new content type. The creation of the English (default) node was fine. When I translated this node to Spanish, the Spanish Title was saved into both the English and Spanish translations. This seems to be the same problem described here.

I just loaded the alpha11 level of code, tried the same scenario and did not have a problem with both translations having the same Title. I'm not sure how this relates to #7. I would be glad to try a scenario and post data if this is helpful.

jhodgdon’s picture

Issue summary: View changes

See comments #4, #5, and #7 for clarification. The problem is actually that the UI for setting up content language settings does not currently match the actual configuration. Field settings for translatable and not translatable are not currently on a per-bundle basis, although the UI shows them that way. So if you have one translatable and one non-translatable bundle (content type), the individual field translation might or might not work, depending on whether the shared title and body and other fields end up being set as "translatable" or not globally. This is being addressed on related issue #2143291: Clarify handling of field translatability

(I've just added this note to the issue summary as well.)

Berdir’s picture

Assigned: plach » jhodgdon
Status: Postponed » Postponed (maintainer needs more info)

The mentioned issue got on, so I expect this to be resolved now. Setting to maintainer needs more info, so that someone can confirm it... jhodgdon? :)

jhodgdon’s picture

FileSize
36.26 KB
30.86 KB

Well, I tested this again on 8.x HEAD. Following the steps in the summary - as far as they go, things are OK. If I make Basic Page translatable, and not Article translatable, and translate the Basic Page, it works OK now.

However, there are still problems:

a) I made Basic Page translatable and left Article as not translatable, but I still see the Translations tab for articles and can add translations to articles. That cannot be correct.
transation settings page
article transations page

b) When I added a translation to the article, it changed the body of the English version. ***I was not warned that this was happening at all*** .. I guess there is a very subtle "Body (all languages)" on the screen, but I really do not feel this is enough of a warning... I guess that is a separate issue, but I do think it's way to subtle in the UI.

c) I then went back to the Article content type and checked the box to make it translatable (with all fields translatable). Went back to the translations and tried to edit the English and French nodes, and I got an error... went to the log and saw:

Exception: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 140 of /home/s71e0ea3f7fa547d/www/core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Not sure what that is about... So I started over with a new article.

That one worked OK.

d) Then I went back to the translation settings page and made body non-translatable for Article and translatable for Basic Page. The UI still lets me do this. It seems to be working as I'd expect -- the body is translatable in one and shared in the other content type. So this part is now working...

So... I guess the issue I reported here is mostly resolved. Should we close this and file new issues for:

1. If you have a bundle that is not translatable, you still get the Translations tab in the UI and the ability to add translations.

2. If you have a bundle that is not translatable and then make it translatable, there may be some editing problems (but this may be related to it not really being translatable? not sure).

3. The UI for telling you that a field is shared across all translations is, IMO, too subtle.

jhodgdon’s picture

Assigned: jhodgdon » Unassigned
Status: Postponed (maintainer needs more info) » Active
jhodgdon’s picture

Status: Active » Fixed

OK. Discussed this briefly with berdir in IRC. I filed:
#2290093: Bundle is not translatable but translations tab / add still there in UI
#2290101: UI telling you a field is shared across languages is way too subtle

I am not sure about the date problem. Unfortunately my simplytest.me session timed out and I am not sure how to reproduce it or if it is an artifact of translating untranslatable content. So I haven't filed an issue about that.

Anyway, the issue reported here is fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

inwebsolutions’s picture

In case anyone stills comes across this issue dumbfounded (as I was), I thought I'd put the link to the solution here.

https://www.drupal.org/node/1280910

It would seem that the module "Title" is indeed required to convert the "Title", and any other, Field onto one that is translatable.

Resolved it for me in minutes I'm happy to say.

hassengh’s picture

I have same problem , someone have solution