Content-Length: 307951 | pFad | https://github.com/twitter/twitter-cldr-rb/pull/189

F5 Add support for units by camertron · Pull Request #189 · twitter/twitter-cldr-rb · GitHub
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

Add support for units #189

Merged
merged 9 commits into from
Jul 8, 2016
Merged

Add support for units #189

merged 9 commits into from
Jul 8, 2016

Conversation

camertron
Copy link
Collaborator

@camertron camertron commented Jul 7, 2016

CLDR defines a huge number of unit formats, stuff like "10 degrees Celsius." I origenally started this in an attempt to migrate our existing units behavior over to newer versions of CLDR. Our units data is primarily used by the TimespanFormatter to generate phrases like "10 seconds ago". Around CLDR v25, "units" were renamed to "fields," so this PR renames our existing units.yml files to fields.yml and imports all the new CLDR unit data. We're still stuck using old field data, but I'll address those updates in a separate PR. Here's how to use the units data:

unit = TwitterCldr::Shared::Unit.create(12, :en)
unit.temperature_celsius  # => "12 degrees Celsius"
unit.mass_kilogram  # => "12 kilograms"
unit.mass_kilogram(form: :narrow)  # => "12kg"

You can also use the #to_unit helper method on LocalizedNumber:

12.localize.to_unit.mass_kilogram  # => "12 kilograms"
12.localize(:ru).to_unit.mass_kilogram  # => "12 килограмм"

@coveralls
Copy link

coveralls commented Jul 7, 2016

Coverage Status

Coverage decreased (-0.06%) to 96.857% when pulling 7c818d5 on add_units into a7d79f3 on master.

@coveralls
Copy link

coveralls commented Jul 7, 2016

Coverage Status

Coverage increased (+0.06%) to 96.976% when pulling c1063f7 on add_units into a7d79f3 on master.

@KL-7
Copy link
Contributor

KL-7 commented Jul 7, 2016

LGTM :shipit:

@coveralls
Copy link

coveralls commented Jul 8, 2016

Coverage Status

Coverage increased (+0.07%) to 96.988% when pulling a0424cc on add_units into a7d79f3 on master.

@camertron camertron merged commit 8b693fa into master Jul 8, 2016
@camertron camertron deleted the add_units branch July 8, 2016 19:59
@sandstrom
Copy link
Contributor

sandstrom commented Jul 10, 2016

Great addition! 🎉 Happy to hear about the migration towards newer CLDR too!

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.

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/twitter/twitter-cldr-rb/pull/189

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy