Closed (fixed)
Project:
Language Hierarchy
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 Mar 2018 at 04:58 UTC
Updated:
30 Dec 2019 at 09:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
james.williamsThe core config system doesn't do translation in the same way as content entities, they use 'language config overrides'. Language hierarchy does not support this yet, thanks for pointing this out!
Patches welcome :-)
Comment #3
geovanni.conti commentedHi.
I tried the following approaches, but I didn't manage to find a solution:
Comment #4
yohanaraujo07@gmail.com commentedComment #5
j-leeI think overriding the LanguageConfigFactoryOverride class is the way we should go.
You can add a new event as a temporarily workaround in src/EventSubscriber/LanguageHierarchyConfigEventSubscriber.php. (Requires the patch from https://www.drupal.org/project/language_hierarchy/issues/2825851)
But it will overrides each language with its fallback.
Comment #6
james.williamsI like the idea! If we're to use events like that, I suspect it may be worth also subscribing to the
DrupalKernelInterface::CONTAINER_INITIALIZE_SUBREQUEST_FINISHEDevent which core's LanguageRequestSubscriber also acts on. I've not actually come across that one before, but I imagine if core acts on that one, we probably should too!But as you say, it overrides the whole language's configuration with that of its fallback, which won't suit many (most?) use cases. I suspect overriding the actual config override system itself in some way to fallback will be needed, but as geovanni.conti found, that may not be easily viable. I'm hopeful there will be a way!
Comment #7
j-leeHere is the patch for the EventSubscriber as described in #5.
Comment #8
james.williamsHere's a version which applies to the latest 8.x-1.x branch code, and adds the same event subscriptions as core's language override subscriber as suggested in comment 6.
Next step will be to figure out if we can override per-config, or make it configurable perhaps. This patch's implementation only falls back a single level too, we should figure out if we should/can go further.
Comment #10
james.williamsHere's a first pass at using real fallbacks for individual config, just to demonstrate an approach. But I haven't done any testing at all with this yet!
Comment #11
james.williamsNote, it's possible that I shouldn't override
getOverride()at all, if I want fallbacks to stay out of a child's config collection entirely, e.g. on writing back to storage?Comment #12
james.williamsOK, so on testing that last patch, it's immediately clear that doesn't work because of circular dependencies in the container, etc.
This one resolves all that. More testing is still needed, but I've ensured this one does at least pick up config from fallback languages. I particularly want to look into what happens on config import/export/installation, as I rather want those situations to remain untouched, ideally. I'm not quite sure of what to do on configuration forms, where translations might show. But this patch is at least a bit more useful now!
Comment #13
james.williamsOK, I think I'm done now. The regular configuration forms now allow writing to a more specific language, when config was coming from a fallback language. The translation overview pages don't highlight languages that are using fallbacks, but they show the 'Add' link for those, which at least demonstrates they don't have their own translation in place. Exporting, importing & installing configuration seems to work as I'd hope.
Comment #14
j-leeWow. Great work!
I've played around with some configurations and translations and can't find any problems until now.
Found only one unused use statement:
Drupal\language\Config\LanguageConfigOverride is never used.
Comment #15
james.williamsGood spot :-) Updated patch here. Only that unused statement has been removed, so I haven't added an interdiff.
I'll leave a little more time for feedback before committing this. I expect to then create a new release candidate version of language hierarchy! :-D
Comment #17
james.williams