fava icon indicating copy to clipboard operation
fava copied to clipboard

Support seperate locales for different commodities

Open Benjamin-Philip opened this issue 6 months ago • 2 comments

Some currencies format their amounts differently from USD. It would like to format the amounts in each currency as they would in their country of origin. Taking the example from the docs, I want the number 1111111.33 to be rendered:

  • 1,111,111.33 with locale en_US for USD
  • 11,11,111.33 with locale en_IN for INR
  • 1.111.111,33 with locale de for EUR.

As of right now the locale can be changed with the locale option for all commodities. I suggest that the locale option be kept as a default for all commodities, and a fava-locale option be introduced as an attribute of a currency:

option "render_commas" "True"
2025-06-13 custom "fava-option" "language" "en"
2025-06-13 custom "fava-option" "locale" "en"

1792-01-01 commodity USD
  name: "US Dollar"
  export: "CASH"

1867-07-01 commodity CAD
  name: "Canadian Dollar"
  export: "CASH"

1947-08-15 commodity INR
  name: "Indian Rupee"
  export: "CASH"
  fava-locale: "en_IN"

So USD and CAD would have locale en while INR would have locale en_IN.

Alternatively, this issue should be transferred to beancount itself. Beancount only renders commas with the en locale and I would like these formatting rules to extend to text output from the CLI and reports that are generated.

Benjamin-Philip avatar Jun 13 '25 04:06 Benjamin-Philip

Sure, why not :) Just one thing could be irritating when using this is that not all places where numbers are rendered (e.g. in queries), there's a known currency, so that could cause inconsistencies. I'd just call the metadata key locale though.

yagebu avatar Jul 27 '25 11:07 yagebu

Cool. Will send a PR soon.

Just one thing could be irritating when using this is that not all places where numbers are rendered (e.g. in queries), there's a known currency, so that could cause inconsistencies

I think that's fine and expected.

I'd just call the metadata key locale though.

I thought you'd want to separate metadata to fava and core beancount. locale is fine with me.

Benjamin-Philip avatar Jul 27 '25 11:07 Benjamin-Philip