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

Could locale modify incl_space and placement parameter? #1593

Open
2 tasks done
olivroy opened this issue Feb 27, 2024 · 1 comment
Open
2 tasks done

Could locale modify incl_space and placement parameter? #1593

olivroy opened this issue Feb 27, 2024 · 1 comment

Comments

@olivroy
Copy link
Contributor

olivroy commented Feb 27, 2024

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..

@rich-iannone
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Next / Ready for Dev
Development

No branches or pull requests

2 participants