Problem/Motivation

Default remote language mappings of a translator are not recreated after changing a translator on Translator settings form...

Proposed resolution

Investigate the problem and fix it. :)

Comments

mbovan created an issue. See original summary.

mbovan’s picture

Status: Active » Needs review
StatusFileSize
new3.59 KB

This patch is created on top of patch 5 uploaded in #2654944: Provide test credentials button and callbacks in base UI class.

I had to add submit callback on "Translator plugin" to (re)update "remote_languages_mapping" on entity and user input...

mbovan’s picture

The last submitted patch, 2: default_remote_language-2654958-2.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: default_remote_language-2654958-3.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Needs review
StatusFileSize
new3.59 KB

Hm, applied easily here. Rerolled..

berdir’s picture

Status: Needs review » Needs work
+++ b/src/Entity/Translator.php
@@ -143,7 +143,7 @@ class Translator extends ConfigEntityBase implements TranslatorInterface {
    */
-  protected $remoteLanguagesMappings = array();
+  protected $remote_languages_mappings = array();

@@ -371,15 +371,15 @@ class Translator extends ConfigEntityBase implements TranslatorInterface {
   public function getRemoteLanguagesMappings() {
-    if (!empty($this->remoteLanguagesMappings)) {
-      return $this->remoteLanguagesMappings;
+    if (!empty($this->remote_languages_mappings)) {
+      return $this->remote_languages_mappings;

This is not correct. the camel case one is a static cache. We already were using the one with underscore before, it just wasn't documented.

mapToRemoteLanguage() then looks again at $this->get('remote_languages_mappings'), that makes no sense like this.

Maybe we no longer need the static or can simplify it elsewhere but this change is definitely not correct.

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new3.58 KB

Is not anymore a property, set to local variable.

berdir’s picture

Status: Needs review » Needs work

We still need to define the actual property remote_languages_mappings like the previous patch did.

Also, would be great to test this. To do this, we need to simulate that a translator doesn't return mappings or they change based on the settings.

berdir’s picture

I'd be OK if we can write those tests using a remote translator like gengo and simulate this behavior there.

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new4.45 KB
new1.41 KB

Re-added the property and some clean up.

We tested manually and it works.
We will add tests in this issue #2655948: Add "Connect" button when we release a new version of tmgmt.
The test will consist on open the translator config form check the default mapping, add the auth keys, ajax will refresh with the server values, to pass the test it must show the previous value instead of the empty value '-'.

berdir’s picture

Status: Needs review » Fixed

Thanks committed.

  • Berdir committed af70c0d on authored by edurenye
    Issue #2654958 by mbovan, edurenye, miro_dietiker: Default remote...

Status: Fixed » Closed (fixed)

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