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 :-)

Comments

jsbalsera created an issue. See original summary.

matsbla’s picture

Thanks for the report! I'll look into this.

Could you upload a patch with your suggested change?

matsbla’s picture

Could you also explain what "problems" you have?

matsbla’s picture

StatusFileSize
new16.72 KB

I'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

matsbla’s picture

StatusFileSize
new16.73 KB
matsbla’s picture

matsbla’s picture

StatusFileSize
new19.62 KB
matsbla’s picture

StatusFileSize
new19.58 KB
matsbla’s picture

StatusFileSize
new22.56 KB
matsbla’s picture

Status: Active » Needs review

@jsbalsera
Can you help test if this patch solves the issue for you?

I will also extend test coverage for the translators permissions.

matsbla’s picture

StatusFileSize
new29.08 KB

Here with tests

  • matsbla committed a7f178a on 8.x-1.x
    Issue #3107275 by matsbla: Default view with Translator Skills
    
matsbla’s picture

Status: Needs review » Fixed

It should be fixed now, but please report back if you encounter more problems.
Thanks for the feedback!

jsbalsera’s picture

Hi! 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!

matsbla’s picture

StatusFileSize
new9.45 KB

That is great! I see now that I forgot to fix coding standards so just cleaning it up.

  • matsbla committed d1ea429 on 8.x-1.x
    Issue #3107275 by matsbla: Coding standard
    

Status: Fixed » Closed (fixed)

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