Background: I have an Angular site, lets say it lives at(Production): aaa.site.com (or localhost:4200) There is a chat page, the chat is inside an iFrame. The chat server lives at(Production): bbb.site.com (or localhost:7078)

Goal: There is some text that displays at certain points of the chat (entering, dialog, ending, etc). It's currently hardcoded into the javascript in the ASPX file in the C# Project. I want to be able to display Spanish versions of these texts.

More background/What I've done for other parts of site: From the Angular site, I have LOCALE. For other parts of the site I can simply send this from an Angular service through our C# WebApi to get spanish version from DB

My Question is: What is the best way to get these translations? These are my thoughts:

  1. Can this still be done through some kind of API call (assuming that Angular and WebAPI live on a different server than ChatServer) ? Could I send the LOCALE from the Angular service to the WebAPI, then have an ajax call from CHATSERVER that accesses the same method from WebAPI to retrieve LOCALE?

    ANGULAR -> API <- CHAT

  2. If this must be done in the javascript in the aspx, then... can I get around the CORS issues? I have looked at multiple SO articles and tried some different ways: https://stackoverflow.com/a/7739035/11187561 this says you can't but there is a workaround. I tried the workaround but still get cross-origin error This shows a potential different workaround: https://stackoverflow.com/a/25098153/11187561 . if this is valid, how does the mainpage postMessage get to the eventListener in a completely different project? https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

Since i've been spending hours on this already, I am looking for a general idea of best path to take forward.

Related posts

Recent Viewed