Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note on locales / currencies #140

Closed
jantman opened this issue Oct 28, 2017 · 2 comments
Closed

Note on locales / currencies #140

jantman opened this issue Oct 28, 2017 · 2 comments

Comments

@jantman
Copy link
Owner

jantman commented Oct 28, 2017

In documentation, add a note on locale/currency support. Should have a clear note near the top of the README, pointing to more detailed explanation in the built docs.

  • ofxgetter
  • Javascript formatting
  • Python formatting
  • Assumptions in DB models around currency values / min/max
@jantman jantman added the ready label Oct 28, 2017
@jantman
Copy link
Owner Author

jantman commented Oct 28, 2017

See also #125 when implementing this. We might as well make some real fixes instead of just adding notes about it. Right now we use Python's built-in locale module for currency formatting internally to the app and in the Python-rendered templates/views. For Javascript, we use a custom function that only knows how to handle USD in en_US.

So, the implementation of this should probably include:

  • Switching the Python code to use Babel as mentioned in Try using alpine-based docker image (musl locale issues) #125
  • Making both the locale and the currency settings options, with the locale defaulting to the system locale if it can be determined, and if not to en_US (except if it's the "C" locale like in the Alpine images), and the currency defaulting to USD.
  • Finding some method of doing appropriate currency formatting in Javascript for the UI-side things.
  • After all that is done, add notes in the docs about any remaining limitations, such as database field size and decimals and anything in ofxgetter.

For the javascript side, there are a number of possibilities:

I think going with the built-in Intl is the way to go. It's as simple as:

var formatted = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(123456.78);

@jantman
Copy link
Owner Author

jantman commented Oct 28, 2017

Ok, what's actually needed for implementation:

  • Make both the locale and the currency settings options, with the locale defaulting to the system locale if it can be determined, or else an env var, or else to en_US (except if it's the "C" locale like in the Alpine images), and the currency defaulting to USD.
  • Switch the Python code from using the locale module to using Babel's format_currency
  • Replace our custom JS formatting function with Intl.NumberFormat, using the locale and currency from the settings file.
  • After all that is done, add docs:
    • Note near top of README for anyone outside en_US / USD to see link to more detailed explanation in the docs
    • Document how to change locale and currency (links to settings) and how they're defaulted
    • Document assumptions in the DB models around numeric length and number of decimals, and willingness to fix this
    • Document that the currency defined in OFX files is ignored by ofxgetter/ofxbackfiller; we assume that there's only one currency in use, and it's the one defined in the settings file
    • Document that the functionality to sync Projects/BOMs with Amazon Wishlists only works for US wishlists, and items in USD.

jantman added a commit that referenced this issue Oct 28, 2017
jantman added a commit that referenced this issue Oct 28, 2017
jantman added a commit that referenced this issue Oct 28, 2017
jantman added a commit that referenced this issue Oct 28, 2017
jantman added a commit that referenced this issue Oct 30, 2017
jantman added a commit that referenced this issue Oct 30, 2017
jantman added a commit that referenced this issue Oct 30, 2017
jantman added a commit that referenced this issue Oct 30, 2017
jantman added a commit that referenced this issue Oct 30, 2017
Issue #140 - configurable currency units and formatting
@jantman jantman reopened this Oct 30, 2017
@jantman jantman closed this as completed Nov 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant