Skip to content

Support specifying format via I18n - #1115

Closed
TastyPi wants to merge 1 commit into
RubyMoney:mainfrom
TastyPi:format-i18n
Closed

TastyPi wants to merge 1 commit into
RubyMoney:mainfrom
TastyPi:format-i18n

Conversation

@TastyPi

@TastyPi TastyPi commented Oct 28, 2024 •

Copy link
Copy Markdown

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

TastyPi commented Oct 28, 2024

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown

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

@sunny

sunny commented Nov 14, 2025

Copy link
Copy Markdown
Member

Hi there @TastyPi, any chance of having another look at this PR? 🙏🏻

@TastyPi

TastyPi commented Nov 17, 2025

Copy link
Copy Markdown
Author

@sunny I'm not currently using Ruby for work, so it's unlikely I'll find capacity any time soon. Feel free to take it over from me.

@yukideluxe

Copy link
Copy Markdown
Member

@sunny I think the linked issue was solved via #1157. I believe we can just close this solution! 😊

@sunny

sunny commented Dec 4, 2025

Copy link
Copy Markdown
Member

Oh yes indeed! 🧹

@sunny sunny closed this Dec 4, 2025
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

4 participants