gt icon indicating copy to clipboard operation
gt copied to clipboard

Could locale modify `incl_space` and `placement` parameter?

Open olivroy opened this issue 1 year ago • 2 comments

Prework

Proposal

I don't really know the mechanism of locale in gt.

But for example, in the "fr_CA" locale, the default would have to be incl_space = TRUE for fmt_percent().

For fmt_currency(incl_space = TRUE, placement = "right") would be the correct thing.

Would it be possible to have these two codes equivalent

# ideally those 2 would be equal
gt::fmt_percent(locale = "fr_CA", incl_space = TRUE)
gt::fmt_percent(locale = "fr_CA")

# ideally those 2 would be equal
fmt_currency(incl_space = TRUE, placement = "right", locale = "fr_CA")
fmt_currency(locale = "fr_CA")

Is there a way to accomplish this?

Edit:

the mechanism would have to go through a new function

for currency, would have to have

placement <- get_currency_placement(currency, placement, locale)

This doesn't seem very efficient because options would have to be added one by one..

olivroy avatar Feb 27 '24 22:02 olivroy

Yes, this can be done and it’s actually something I’ve put off for far too long!

With these locale-specific parameters the default should be none and the locale would obtain the correct values from CLDR data. The arguments would then serve as overrides.

rich-iannone avatar Feb 28 '24 00:02 rich-iannone