Hat tip to @jhodgdon for finding this.
Problem/Motivation
The title label of node types cannot be translated currently using the Config Translation module.
Proposed resolution
Node types use base field overrides to manage the title label and integrate them with the node type form in a custom way. Therefore they should take care of adding the respective config objects to the node type translation form.
A dedicated NodeTypeMapper should be added for this.
Remaining tasks
User interface changes
Adds a field to translate the node type title label.


API changes
None.
Data model changes
None.
Beta phase evaluation
| Issue category | It's a bug since the node type title label should be translatable from the UI. |
|---|---|
| Issue priority | Not critical because it doesn't break anything. |
| Unfrozen changes | Unfrozen because it only add a field to translate the node type title label on the translate tab on the node type page. |
| Prioritized changes | The main goal of this issue is usability because otherwise the node type title label is not translatable from the UI. |
| Disruption | Undisruptive. |
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | after.png | 45.48 KB | maxocub |
| #27 | before.png | 41.51 KB | maxocub |
| #20 | interdiff.txt | 7.25 KB | maxocub |
| #20 | translate_node_type_title_label-2571337-20.patch | 7.43 KB | maxocub |
| #12 | interdiff.txt | 3.95 KB | maxocub |
Comments
Comment #2
maxocub commentedAm I understanding correctly that we want to add a line for the 'Title' on the 'Manage fields' page of content types thus making available the 'Translate' link?
Comment #3
rodrigoaguileraAt the interface level I think it should be in this screenshot rather than adding a row there.
with the rest of node type configurations.
Comment #4
maxocub commentedYes, you're right, I cleared that up with Gabor earlier, thanks.
Comment #5
maxocub commentedI added a NodeTypeMapper where I add the title label to the translation form. Thanks @tstoeckler for your help!
Two things to note:
1) The title label is displayed on the translation form only if it has been edited first because of those lines in NodeTypeForm.php (lines 243-245):
2) There is also a 'Help text' field that gets added, and I don't know where it comes from (see screenshot). Maybe you have an idea @gábor-hojtsy? It's not on the node type edit form and if I set a translation for it, I don't see it when I export the configuration.
Comment #7
maxocub commentedComment #8
maxocub commentedComment #10
tstoecklerThis looks really great, thanks a lot for taking this on! I have almost nothing to complain about, only a couple tiny things. What this issue will need, though, is some test coverage. I.e. a test that asserts that the title label field is found on the translation page and also that the correct title label actually shows up on the node edit form. Marking needs work (mostly) for that and tagging accordingly.
Some comments on the code:
This is the first time a moduel other that config_translation is providing a translation mapper, so there's no standard to go by (yet), but I personally dislike "polluting" the top-level namespace of modules. My proposal would be to move this class into the
\Drupal\node\ConfigTranslationnamespace. Thoughts?This should be a complete sentence. We often use something like "Provides a ..." (i.e. "Provides a configuration mapper for node types.")
This makes a lot of sense, great work!
@maxocub asked me whether we should add the other base field overrides (promoted, ...) as well. My initial response was "no", because they don't provide any translatable settings. However - like any config entity - they support third party settings, so they could be extended in contrib, with translatable information. So - having thought about it - I actually would suggest to add them here as well.
However, that will currently not work due to #2571655: ConfigNamesMapper::hasTranslatable has flawed logic, so let's leave that out for now.
(I.e. nothing to do for this bullet point.)
Comment #12
maxocub commentedHere's a new patch with a test and the two changes from #10.
Comment #15
tstoecklerAwesome work on the test, that is exactly what we need to test, very, very nicely done.
I have two minor comments before this is RTBC from my point of view (once it's green).
Instead of adding this to the already really convoluted
ConfigTranslationUiTestI think we should create a newNodeTypeTranslationTestin Node module.Instead of hardcoding the translated path here, you should pass
['language' => new Language(['id' => 'fr'])]into $options.Comment #16
maxocub commentedAbout #15/1, beside moving my new test to the new file, I guess I should also move 'testNodeTypeTranslation' there?
I still find it pretty weird that we have to edit the title label first to be able to translate it. Shouldn't we improve that. I'm still trying to figure out how to get rid of the exception from the tests, and it seems to be related.
Comment #17
jaxxed commented@maxocub are you still on this? (it is currently unassigned)
Comment #18
maxocub commented@jaxxed: yes I am! Assigned.
Comment #19
tstoecklerYes, please!! :-) Anything that makes this terrible (because terribly long to run) test smaller is very much appreciated.
Comment #20
maxocub commented#15/1:
I put the two node type tests in the new 'NodeTypeTranslationTest.php'
#15/2:
I haven't succeeded to put the language into the options of drupalGet, I don't know why, it always give me the English path. I removed the hardcoded 'fr' and used $langcode instead, I don't know if it makes it better...
About the exception from the earlier test results, I modified the test 'testNodeTypeTranslation' to edit the node title before trying to add a new translation. This is a hack around the fact that we can't translate a title label unless it has been modified before.
Comment #21
maxocub commentedComment #22
rodrigoaguileraGreat work! Thank you
I tested this on the interface and it makes the label translatable.
Maybe it was not working for you because the language option in drupalGet must be a language object
For example
$language = \Drupal::languageManager()->getLanguage($langcode);
$this->drupalGet('node/8', ['language' => $language]);
https://api.drupal.org/api/drupal/core!modules!simpletest!src!WebTestBas...
Does this need a beta evaluation?
Comment #23
maxocub commented@rodrigoaguilera: I did use the language object with drupalGet() (and I just tried again) and it always give me the English path anyway.
I tried this:
and also:
Comment #24
rodrigoaguileraOk,
I realized you have to call
$this->rebuildContainer();
if you want those 2 calls to work but to put the langcode in the URL is not that ugly and happens in other tests.
So from my point of view The only thing missing is the beta evaluation.
Comment #25
maxocub commentedComment #26
rodrigoaguileraGreat!
Comment #27
maxocub commentedAdded screen shots to the summary.
Comment #28
gábor hojtsyLooks good to me too, thanks!
Comment #29
alexpottNice tests and nice fix. Committed e16b2b0 and pushed to 8.0.x. Thanks!
Comment #31
gábor hojtsyYay, thanks all!
Comment #33
maxocub commentedComment #34
maxocub commentedComment #35
maxocub commented