membermatters / MemberMatters

An open source membership, access and payments portal for makerspaces and community groups.
https://membermatters.org
MIT License
40 stars 23 forks source link

Allow for localisation of Currency #185

Closed proffalken closed 1 year ago

proffalken commented 1 year ago

Is your feature request related to a problem? Please describe.

At the moment, all currency values are prefixed with a $, which is fine for a staggering number of countries, but no good if you're in a country that doesn't use a dollar-prefixed currency!

Describe the solution you'd like

I should be able to set the currency prefix via the application settings in Constance

Describe alternatives you've considered

N/A

Additional context

As discussed on Discord, we probably need to make sure this change is carried through to Stripe and anywhere else currency might be handled.

jabelone commented 1 year ago

Following on from #188:

I couldn't help myself and jumped in there just now. Looks like it was only slightly more complex than I thought. Take a look at the most recent commit to the dev branch (link), but that should implement support for detecting the browser's locale and rendering the correct language/number format. Give it a go and let me know how it goes for you!

All that needs to happen for new languages now is a new translation definition (+ translations) and the number format needs to be added.

Screen Shot 2022-08-29 at 9 37 26 pm

Just waiting on @proffalken to confirm this fixes the currency issue for them, then I can close off this card.

proffalken commented 1 year ago

@jabelone - looks good to me based on the current Dev Branch, really appreciate this, thanks!

jabelone commented 1 year ago

Great! I’ll do up a release shortly :)

jabelone commented 1 year ago

I've just tested the latest release by updating the language setting on my iPhone to English (UK) and refreshing the page. The prices all updated to show the currency using the pounds symbol rather than dollar signs. If you find any other places that need updating or related issues please let me know, but this looks resolved now. :)

snoopen commented 1 year ago

Just gonna throw in my two cents. I don't think this is the right way to handle currencies. It should be configured server side. That ensures even if a user has an odd region set they'll still see the correct currency used by that makerspace.

jabelone commented 1 year ago

Completely agree! At first thought I considered currency a "translation issue" rather than a "money issue" but after thinking further I completely agree - that was a rather silly oversight by me. I think the best way is to add a Django constance variable with the locale that the translation library should use for currency. That way the correct currency symbol will always be used but the frontend can localise the rest of the UI.

jabelone commented 1 year ago

I've made a new release with a way to configure a specific locale for all currency formatting. This should hopefully work better! https://github.com/membermatters/MemberMatters/releases/tag/v3.2.0