Skip to content

Support specifying format via I18n #1115

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TastyPi
Copy link

@TastyPi TastyPi commented Oct 28, 2024

What's changing?

Allow the default format for a language be configured via I18n.

Why?

Fixes #233 (which was closed with no solution).

This is blocking us from launching our product in France.

@TastyPi
Copy link
Author

TastyPi commented Oct 28, 2024

It uses the key number.currency.format.format, which I don't love, suggestions welcome.

Comment on lines +71 to +75
begin
rules[:format] ||= I18n.t :format, scope: "number.currency.format", raise: true
rescue I18n::MissingTranslationData
# Do nothing
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this code could be move to determine_format_from_formatting_rules since :symbol_position, :symbol_before_without_space and :symbol_after_without_space are deprecated options.

Something like:

def determine_format_from_formatting_rules(rules)
  begin
    I18n.t :format, scope: "number.currency.format", raise: true
  rescue I18n::MissingTranslationData
    return currency.format if currency.format && !rules.has_key?(:symbol_position)
    symbol_position = symbol_position_from(rules)
    if symbol_position == :before
      rules.fetch(:symbol_before_without_space, true) ? '%u%n' : '%u %n'
    else
      rules[:symbol_after_without_space] ? '%n%u' : '%n %u'
    end
  end
end

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

Successfully merging this pull request may close these issues.

with the french locale (and others), the euro symbol should be appended, not prepened
2 participants