compound-finance / palisade

Compound Web3 Front-end
https://v2-app.compound.finance
GNU General Public License v3.0
111 stars 83 forks source link

respect locale query param lang in v2 dapp #65

Closed kevjin closed 1 year ago

kevjin commented 1 year ago

The locale query param sets the user's language on the Elm model on init: https://github.com/compound-finance/palisade/blob/cc4b0bc0ff08d3aab76477a642b3461dd21a5241/src/js/dapp.js#L69 but then it quickly gets overridden when listening to updates here: https://github.com/compound-finance/palisade/blob/cc4b0bc0ff08d3aab76477a642b3461dd21a5241/src/elm/Main.elm#L1058 and what's interesting is that the sent preferences message could be empty if local storage is not set, so it'll default to English: https://github.com/compound-finance/palisade/blob/cc4b0bc0ff08d3aab76477a642b3461dd21a5241/src/js/ports.js#L551

This fix basically sets the user language to be based on the locale query param, if there are no user preferences defined in local storage already.