Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Translations of Static Elements are broken #1280

Closed
metas-mk opened this issue Oct 19, 2017 · 13 comments
Closed

Translations of Static Elements are broken #1280

metas-mk opened this issue Oct 19, 2017 · 13 comments

Comments

@metas-mk
Copy link
Member

Is this a bug or feature request?

Bug

What is the current behavior?

Currently, the Translations of Static Elements are broken

Which are the steps to reproduce?

Switch your User Language to en_US and check different static Elements. All are shown in de_DE Base Language.

What is the expected or desired behavior?

Shall be translated again

image

@teosarca
Copy link
Member

might be related with #1092 (comment)

@metas-mk
Copy link
Member Author

Have to recheck, how to reproduce.

@ottosichert ottosichert self-assigned this Nov 5, 2017
@ottosichert
Copy link
Contributor

  • Click on avatar top right
  • Click on settings
  • Open SideList
  • Elements in current language => OK
  • Select new language
  • Loading indicator flashes
  • Open SideList
  • Elements still in old language => NOK
  • Refresh page
  • Open SideList
  • Now elements in new language => OK

@ottosichert
Copy link
Contributor

I could narrow the problem down to these two issues:

  1. The layout is not fetched again after changing the language
    • I couldn't find a backend trigger indicating this, so the only way right now is to use hardcoded values to determine whether the language field in user settings is changed
    • see my PR
    • TODO 1: Trigger layout re-fetch from backend
    • TODO 2: Register backend trigger and re-fetch layout
  2. The backend reacts extremely slowly to language changes. Besides that it's by no means the expected behaviour, because the PATCH request to http://w101.metasfresh.com:8081/rest/api/window/53100/userid123 with data [{"op":"replace","path":"AD_Language","value":{"de_DE":"Deutsch (DE)"}}] returns 200 OK. This can be observed by following steps:
    • Racing against the backend:
      • Select new language
      • Immediately refresh page
      • Still in old language, but language dropdown shows new language!
      • Wait a bit, refresh page again
      • New language applied, language dropdown show new language
    • Brute forcing:
      • Select new language (1)
      • Select old language (2)
      • Select new language (1) again
      • Sometimes the new language will be applied, but most of the time it won't
    • TODO 3a: Do not return 200 OK if language change is not completed
    • TODO 3b: or make the backend react fast enough (could still lead to race conditions though)
    • TODO 3c: or solve this issue with TODO 1 and TODO 2 asynchronously

@teosarca
Copy link
Member

teosarca commented Nov 6, 2017

hi @ottosichert ,
thanks for taking care but i think this task would be solved completely and generically by metasfresh/metasfresh-webui-api-legacy#660 .

Let's wait for next rollout on w101 and check again.
I've quickly checked on my laptop and it seems to work.
wdyt?

@teosarca
Copy link
Member

teosarca commented Nov 7, 2017

guys, i am moving this task directly to testing... IMHO the problem was fixed by metasfresh/metasfresh-webui-api-legacy#660 .

pls ping me if I am missing something...

@teosarca
Copy link
Member

teosarca commented Nov 7, 2017

update: just tested the case desribed by Mark... not working.
But on the other side i don't know if the fix shall be the same.
@ottosichert can u pls check it again?

@teosarca
Copy link
Member

update: i think we still need code changes, but the frontend shall react on user session changed event, from websocket (which now! works) instead of harcoding the windowId and field...

@ottosichert
Copy link
Contributor

@teosarca I can not test the websocket event because I can not change the language since a new database was set up for w101.

This is the case for both roles (Admin and WebUI) of user metasfresh. Can you give me a new account or enable language settings for this account?

@teosarca
Copy link
Member

@ottosichert i've created u an account (sent the credentials).
While checking pls also make sure the correct language is used even when for example i login with English, logout and login with an account which is using German language.

@ottosichert
Copy link
Contributor

This websocket issue was hard to comprehend in frontend code.

Current status:

  • Select new language
  • PATCH request to http://w101.metasfresh.com:8081/rest/api/window/53100/2188233 is sent
    Show request body
    [
      {
        "op": "replace",
        "path": "AD_Language",
        "value": {
          "key": "de_DE",
          "caption": "Deutsch (DE)"
        }
      }
    ]
    
  • PATCH request return 200 OK
    Hint: If you need to verify this and use chrome devtools, use this to examine response payloads before they are disposed: window.onbeforeunload = () => { debugger; }
    Show response body
    [
      {
        "windowId": "53100",
        "id": "2188233",
        "fieldsByName": {
          "AD_Language": {
            "field": "AD_Language",
            "value": {
              "key": "de_DE",
              "caption": "Deutsch (DE)"
            },
            "widgetType": "List",
            "validStatus": {
              "valid": true,
              "initialValue": true,
              "fieldName": "AD_Language"
            }
          },
          "V$DocumentSummary": {
            "field": "V$DocumentSummary",
            "value": "Sichert, Otto",
            "widgetType": "Text"
          }
        },
        "websocketEndpoint": "/document/53100/2188233"
      }
    ]
    
  • Message is sent via /userSession/2188233 websocket
    Show websocket frame
    a["MESSAGE
    destination:/userSession/2188233
    content-type:application/json;charset=UTF-8
    subscription:sub-0
    message-id:prqitvr3-197
    content-length:92
    {"language":{"key":"de_DE","caption":"Deutsch"},"timestamp":"2017-11-22T01:06:15.282+01:00"}"]
    
  • Frontend reacts to websocket and dispatches USER_SESSION_UPDATE action
    https://github.com/metasfresh/metasfresh-webui-frontend/blob/9933b1a214f5d0392b82326382ac99a973f10f33/src/actions/AppActions.js#L252-L254
  • <Header> component reloads page in componentDidUpdate()
    https://github.com/metasfresh/metasfresh-webui-frontend/blob/9933b1a214f5d0392b82326382ac99a973f10f33/src/components/header/Header.js#L89
  • Page is reloaded, but the language is not updated immediately! If you refresh the page after a few seconds, the language will display correctly. => NOK

As the websockets work correctly, I will close #1318. I'm glad we can avoid this workaround :)

While checking pls also make sure the correct language is used even when for example i login with English, logout and login with an account which is using German language.

@teosarca After playing a little bit with changing languages and logging in and out I found out, the issue (regarding delayed usage of new language) even persists through user sessions, i.e.:

  • Change language
  • Page still in old language as described above
  • Logout
  • Login
  • Page still in old language => NOK
  • Refresh after a few seconds
  • New language is applied => OK

Otherwise changing language works as intended. The login dialog shows Password for English (US) and Passwort for Deutsch (DE) depending on the last selected language. After logging in the current user's language is correctly used.

@teosarca
Copy link
Member

@ottosichert yup, those are the NOKs which needs to be fixed

@teosarca
Copy link
Member

reported issues shall be fixed by metasfresh/metasfresh-webui-api-legacy#701 .

note to IT: pls also check the Menu, Home etc tooltips.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants