All Projects → cuducos → elm-format-number

cuducos / elm-format-number

Licence: BSD-3-Clause license
✨Format numbers as pretty strings

Programming Languages

elm
856 projects

Projects that are alternatives of or similar to elm-format-number

React Phone Input 2
📞 Highly customizable phone input component with auto formatting
Stars: ✭ 446 (+696.43%)
Mutual labels:  i18n, format
bcp-47-normalize
Normalize, canonicalize, and format BCP 47 tags
Stars: ✭ 16 (-71.43%)
Mutual labels:  i18n, format
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (-66.07%)
Mutual labels:  i18n, format
Translatedjs
Internationalization and localization for JavaScript and Node.js
Stars: ✭ 17 (-69.64%)
Mutual labels:  i18n, format
googlejavaformat-action
GitHub Action that formats Java files following Google Style guidelines
Stars: ✭ 66 (+17.86%)
Mutual labels:  format
TranslationFiles
[READ-ONLY] This repo contains all the necessary files to generate translation packs for PrestaShop 1.6 and 1.7. It's updated automatically.
Stars: ✭ 16 (-71.43%)
Mutual labels:  i18n
react-i18next-phraseapp
Library support to use react-i18next with the Phrase In-Context Editor - DEPRECATED
Stars: ✭ 14 (-75%)
Mutual labels:  i18n
motivational-numerology
Simple web page to calculate and interpret the numerology numbers derived from your name and birth date (in English, French, and Turkish).
Stars: ✭ 23 (-58.93%)
Mutual labels:  numbers
fyodor
Convert your Amazon Kindle highlights and notes into markdown (or any format).
Stars: ✭ 101 (+80.36%)
Mutual labels:  i18n
vue-translations
VueJs translations very similar to Laravel Translation system
Stars: ✭ 15 (-73.21%)
Mutual labels:  i18n
ExcelCollectionViewLayout
An Excel-like UICollectionView's layout.
Stars: ✭ 32 (-42.86%)
Mutual labels:  numbers
unicode-programming
Unicode programming examples
Stars: ✭ 33 (-41.07%)
Mutual labels:  i18n
li18nt
🌎 Lint your i18n translation files. Detect conflicting properties, duplicates and make it more readable and easier to maintain by formatting it!
Stars: ✭ 29 (-48.21%)
Mutual labels:  i18n
android-studio-plugin
Integrate your Android project with Crowdin
Stars: ✭ 52 (-7.14%)
Mutual labels:  i18n
D-i18n
前端国际化通用解决方案。抹平不同前端开发技术栈所带来的差异。
Stars: ✭ 85 (+51.79%)
Mutual labels:  i18n
bcp-47
Parse and stringify BCP 47 language tags
Stars: ✭ 51 (-8.93%)
Mutual labels:  i18n
next
(Work in progress) The rewritten version of the original PizzaQL 🍕
Stars: ✭ 45 (-19.64%)
Mutual labels:  i18n
ra-language-japanese
Japanese messages for react-admin
Stars: ✭ 22 (-60.71%)
Mutual labels:  i18n
enumize
Extend ActiveRecord::Enum for add more helpful methods.
Stars: ✭ 25 (-55.36%)
Mutual labels:  i18n
I18N
I18N Library for .NET, and Delphi
Stars: ✭ 48 (-14.29%)
Mutual labels:  i18n

Elm Format Number Build

This simple Elm package formats Float numbers as pretty strings.

Format

The format function formats Float numbers using a locale with settings:

import FormatNumber exposing (format)
import FormatNumber.Locales exposing (spanishLocale, usLocale)

format usLocale (pi * 1000)  --> "3,141.59"
format spanishLocale (pi * 1000)  --> "3.141,593"

It is flexible enough to deal with different number of decimals, different thousand separators, different decimal separator, and different ways to represent negative numbers — all that is possible using Locales. The base locale matches Elm's native String.fromFloat using unicode minus (U+2212) instead of an hyphen/dash.

import FormatNumber exposing (format)
import FormatNumber.Locales exposing (Decimals(..), Locale, usLocale)

sharesLocale : Locale
sharesLocale =
    { usLocale
        | decimals = Exact 3
        , negativePrefix = "("
        , negativeSuffix = ")"
    }

format usLocale -pi --> "−3.14"
format sharesLocale -pi --> "(3.142)"

The Decimals strategy type

Decimals type contains different strategies for handling the number of decimals when formatting the number.

  • Min Int shows at least a certain amount of decimal digits, adding trailing zeros if needed.
  • Max Int shows up to a certain amount of decimal digits, discarding trailing zeros if needed.
  • Exact Int shows an exact number of decimal digits, adding trailing zeros if needed.

Docs

The API is further documented in package.elm-lang.org.

Tests

This package uses elm-verify-examples, all the examples in the documentation are automatically tested:

$ npm install
$ npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].