{"action":"created","issue":{"url":"https://api.github.com/repos/shopware/shopware/issues/1289","repository_url":"https://api.github.com/repos/shopware/shopware","labels_url":"https://api.github.com/repos/shopware/shopware/issues/1289/labels{/name}","comments_url":"https://api.github.com/repos/shopware/shopware/issues/1289/comments","events_url":"https://api.github.com/repos/shopware/shopware/issues/1289/events","html_url":"https://github.com/shopware/shopware/pull/1289","id":260959168,"number":1289,"title":"Fix config select store value translation logic","user":{"login":"fixpunkt","id":2817302,"avatar_url":"https://avatars1.githubusercontent.com/u/2817302?v=4","gravatar_id":"","url":"https://api.github.com/users/fixpunkt","html_url":"https://github.com/fixpunkt","followers_url":"https://api.github.com/users/fixpunkt/followers","following_url":"https://api.github.com/users/fixpunkt/following{/other_user}","gists_url":"https://api.github.com/users/fixpunkt/gists{/gist_id}","starred_url":"https://api.github.com/users/fixpunkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fixpunkt/subscriptions","organizations_url":"https://api.github.com/users/fixpunkt/orgs","repos_url":"https://api.github.com/users/fixpunkt/repos","events_url":"https://api.github.com/users/fixpunkt/events{/privacy}","received_events_url":"https://api.github.com/users/fixpunkt/received_events","type":"User","site_admin":false},"labels":[{"id":318046718,"url":"https://api.github.com/repos/shopware/shopware/labels/Scheduled","name":"Scheduled","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-09-27T12:42:08Z","updated_at":"2018-05-02T16:01:22Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/shopware/shopware/pulls/1289","html_url":"https://github.com/shopware/shopware/pull/1289","diff_url":"https://github.com/shopware/shopware/pull/1289.diff","patch_url":"https://github.com/shopware/shopware/pull/1289.patch"},"body":"### 1. Why is this change necessary?\r\n\r\n[This line here](https://github.com/shopware/shopware/commit/db7b41e813b456e081576e222130d9482d384ae2#diff-82dab508fe5ae6234ffc4ea20d371fc8R187) tries to implement a language fallback logic for translated config select store values, but in doing so overwrites the loaded store array which contains the translations. This leads to the problem that the following call to `translateStore`, which should perform the real, non-fallback store translation, only finds the \"fallback\" and thus fails to translate the store values. This means that translation of config select store values is broken in Shopware 5.3.\r\n\r\nThis is the line in question:\r\n\r\n```php\r\n$values['options']['store'] = $this->translateStore('en', $values['options']['store']);\r\n```\r\nI'm also not really sure what the intended effect of this line is, since the documentation of `\\Shopware_Controllers_Backend_Config::translateStore()` states that it expects a full locale as its first argument, but here, only an ISO 639-1 language code is given. Also, `translateStore()` already performs a fallback if no key matching the given locale exists by just using the first translation in this case. @OliverSkroblin, can you offer more insight on this?\r\n\r\n### 2. What does this change do, exactly?\r\n\r\nIt makes a copy of the loaded config store with all translations intact before performing the fallback logic.\r\n\r\nPlease note that if my intuition is correct and the fallback line is not actually needed at all, the best approach is probably to just remove that fallback and reject this PR.\r\n\r\n### 3. Describe each step to reproduce the issue or behaviour.\r\n\r\n1. Have a plugin with a translated config select store, e.g. like this config field from Pickware ERP:\r\n    ```php\r\n    $form->setElement(\r\n        'select',\r\n        'purchasePriceMode',\r\n        [\r\n            'label' => 'Eingabe von Einkaufspreisen',\r\n            'description' => 'Wählen Sie den Modus, in dem Einkaufspreise eingegeben/angezeigt werden sollen.',\r\n            'value' => 'net',\r\n            'store' => [[\r\n                'net',\r\n                [\r\n                    'de_DE' =>'Netto',\r\n                    'en_GB' => 'Net'\r\n                ],\r\n            ], [\r\n                'gross',\r\n                [\r\n                    'de_DE' => 'Brutto',\r\n                    'en_GB' => 'Gross'\r\n                ]\r\n            ]]\r\n        ]\r\n    );\r\n    ```\r\n2. Log in with a locale of `en_GB`.\r\n3. Open the plugin config and observe that the select value is shown in German instead of English.\r\n\r\n### 4. Please link to the relevant issues (if any).\r\n\r\nNone.\r\n\r\n### 5. Which documentation changes (if any) need to be made because of this PR?\r\n\r\nNone.\r\n\r\n### 6. Checklist\r\n\r\n- [X] I have written tests and verified that they fail without my change\r\n- [X] I have squashed any insignificant commits\r\n- [X] This change has comments for package types, values, functions, and non-obvious lines of code\r\n- [X] I have read the contribution requirements and fulfil them."},"comment":{"url":"https://api.github.com/repos/shopware/shopware/issues/comments/386029743","html_url":"https://github.com/shopware/shopware/pull/1289#issuecomment-386029743","issue_url":"https://api.github.com/repos/shopware/shopware/issues/1289","id":386029743,"user":{"login":"fixpunkt","id":2817302,"avatar_url":"https://avatars1.githubusercontent.com/u/2817302?v=4","gravatar_id":"","url":"https://api.github.com/users/fixpunkt","html_url":"https://github.com/fixpunkt","followers_url":"https://api.github.com/users/fixpunkt/followers","following_url":"https://api.github.com/users/fixpunkt/following{/other_user}","gists_url":"https://api.github.com/users/fixpunkt/gists{/gist_id}","starred_url":"https://api.github.com/users/fixpunkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fixpunkt/subscriptions","organizations_url":"https://api.github.com/users/fixpunkt/orgs","repos_url":"https://api.github.com/users/fixpunkt/repos","events_url":"https://api.github.com/users/fixpunkt/events{/privacy}","received_events_url":"https://api.github.com/users/fixpunkt/received_events","type":"User","site_admin":false},"created_at":"2018-05-02T16:01:21Z","updated_at":"2018-05-02T16:01:21Z","author_association":"CONTRIBUTOR","body":"All credit goes to @cjuner for reworking this PR. Maybe you can give a summary of your improvements?"}}
{"actor":{"display_login":"fixpunkt"}}