Hi everyone.
First of all thank you for the work in this module, that provides a very useful functionality.
I have been checking the module just to test it, together with translators to use the translation skills, installed with the Umami profile with a third language. I have been trying to use the default view with a non-admin user with some problems, and I don't know exactly if any of the local changes are responsible of them, or maybe it's about this module or the translators one. Thing is, the user created for the test have the translation skill for English to German (the third language), and the `Create translations (in translation skills)` permission. When accessing the view, in English, the operations never showed the create translation button and, debugging, what I saw is that the function `getTranslationAccess` calls the same function in the AccessHandler just passing the entity and the operation, without the source or target langcodes. Then the `TranslatorsContentTranslationHandlerTrait.php` (I understand that this is part of another project, so if I should ask in the other issue queue please just tell me), given that it doesn't receive the codes, check for the route and, after that, just use the current language, and checks for English for both the source and target language for the translation.
What I did to make it work was to change this in `src/EntityTranslationInfo.php`:
public function getTranslationAccess($operation) {
$sourceId = $targetId = NULL;
if ($this->sourceLanguage instanceof LanguageInterface) {
$sourceId = $this->sourceLanguage->getId();
}
if ($this->targetLanguage instanceof LanguageInterface) {
$targetId = $this->targetLanguage->getId();
}
$access = $this->accessHandler->getTranslationAccess($this->entity, $operation, $sourceId, $targetId);
return $access->isAllowed();
}
But I understand that may not be the best solution, given that the `ContentTranslationHandlerInterface` defines the getTranslationAccess with just two params, even if for the submodule the implementation accepts four.
Did I do something wrong? If not, maybe adding the two extra params would be ok? Or should I write an issue in the translators issue queue?
Thank you :-)
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | clean-up-coding-standards.patch | 9.45 KB | matsbla |
| #11 | default-view-with-translation-skills-7.patch | 29.08 KB | matsbla |
Comments
Comment #2
matsbla commentedThanks for the report! I'll look into this.
Could you upload a patch with your suggested change?
Comment #3
matsbla commentedCould you also explain what "problems" you have?
Comment #4
matsbla commentedI've made an attempt to solve this, I've removed EntityTranslationInfo as it seem quite redundant, and tried to update /src/Plugin/views/field/TranslationOperationsField.php
Then tried to work around the differences in parameters by checking if translators_content module is enabled.
Also did some simplification of code in TranslationOperationsField.php
Comment #5
matsbla commentedComment #6
matsbla commentedComment #7
matsbla commentedComment #8
matsbla commentedComment #9
matsbla commentedComment #10
matsbla commented@jsbalsera
Can you help test if this patch solves the issue for you?
I will also extend test coverage for the translators permissions.
Comment #11
matsbla commentedHere with tests
Comment #13
matsbla commentedIt should be fixed now, but please report back if you encounter more problems.
Thanks for the feedback!
Comment #14
jsbalseraHi! Really sorry for the radio silence, the flu hit me hard :D I have checked the patch and tested locally, and it does the work. Thank you!
Comment #15
matsbla commentedThat is great! I see now that I forgot to fix coding standards so just cleaning it up.