{"id":13726582,"url":"https://github.com/opendevtools/rescript-intl","last_synced_at":"2025-05-07T21:33:17.208Z","repository":{"id":42392454,"uuid":"248215566","full_name":"opendevtools/rescript-intl","owner":"opendevtools","description":"ReScript wrapper on top of JavaScript's Intl","archived":true,"fork":false,"pushed_at":"2023-03-31T06:18:08.000Z","size":212,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-14T16:45:32.237Z","etag":null,"topics":["currency","currency-formatting","date-formatting","intl","number-formatting","rescript"],"latest_commit_sha":null,"homepage":"","language":"ReScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opendevtools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-03-18T11:40:43.000Z","updated_at":"2023-03-31T06:18:10.000Z","dependencies_parsed_at":"2024-01-10T19:10:53.428Z","dependency_job_id":null,"html_url":"https://github.com/opendevtools/rescript-intl","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opendevtools%2Frescript-intl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opendevtools%2Frescript-intl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opendevtools%2Frescript-intl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opendevtools%2Frescript-intl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opendevtools","download_url":"https://codeload.github.com/opendevtools/rescript-intl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252957513,"owners_count":21831501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["currency","currency-formatting","date-formatting","intl","number-formatting","rescript"],"created_at":"2024-08-03T01:03:13.624Z","updated_at":"2025-05-07T21:33:16.931Z","avatar_url":"https://github.com/opendevtools.png","language":"ReScript","funding_links":[],"categories":["ReScript"],"sub_categories":[],"readme":"## **DEPRECATED:** Use bindings from [rescript-core](https://github.com/rescript-association/rescript-core) instead.\n\n# rescript-intl\n\n[![](https://github.com/opendevtools/rescript-intl/workflows/Release/badge.svg)](https://github.com/opendevtools/rescript-intl/actions?workflow=Release)\n[![npm (scoped)](https://img.shields.io/npm/v/@opendevtools/rescript-intl)](https://npm.im/@opendevtools/rescript-intl)\n\n`rescript-intl` helps you with date, number and currency formatting in ReScript.\nEverything is built on top of [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) which comes built-in with\nbrowsers \u003e= IE11 as well as Node.\n\n## Get started\n\n```\nnpm install @opendevtools/rescript-intl\n```\n\nAdd `rescript-intl` in `bsconfig.json`\n\n```\n{\n  \"dependencies\": [\"@opendevtools/rescript-intl\"]\n}\n```\n\n## Examples\n\n### DateTime\n\n```reason\nlet today = Intl.DateTime.make(~locale=Some(\"sv\"), ());\n// today: string = \"2020-03-18\"\n```\n\nwith custom date\n\n```reason\nlet date = Js.Date.makeWithYMD(~year=2020., ~month=11., ~date=12., ());\n\nlet futureDate = Intl.DateTime.make(~date, ~locale=Some(\"sv\"), ());\n// futureDate: string = \"2020-12-12\"\n```\n\nwith date as string\n\n```reason\nlet futureDate = Intl.DateTime.makeFromString(~date=\"2020-11-12\", ~locale=Some(\"sv\"), ());\n// futureDate: string = \"2020-11-12\"\n```\n\nand with some `options`\n\n```reason\nlet today =\n  Intl.DateTime.make(\n    ~locale=Some(\"sv\"),\n    ~options=\n      Options.make(\n        ~year=Some(#numeric),\n        ~weekday=Some(#long),\n        ~day=Some(#\"2-digit\"),\n        ~era=Some(#narrow),\n        ~month=Some(#long),\n        (),\n      ),\n    (),\n  );\n// today: string = \"onsdag 18 mars 2020 e.Kr\".\n```\n\n### NumberFormat\n\n#### Currency\n\n```reason\nlet krona =\n  Intl.NumberFormat.Currency.make(\n    ~value=1000.,\n    ~currency=\"SEK\",\n    ~locale=Some(\"sv\"),\n    (),\n  );\n// krona: string = \"1 000,00 kr\"\n```\n\n#### Decimal\n\n```reason\nlet parsedNumber =\n  Intl.NumberFormat.Decimal.make(~value=1000., ~locale=Some(\"sv\"), ());\n// parsedNumber: string = \"1 000,00\"\n```\n\n#### Percent\n\n```reason\nlet percent =\n  Intl.NumberFormat.Percent.make(~value=0.3456., ~locale=Some(\"sv\"), ());\n// percent: string = \"34,56 %\"\n```\n\n### ListFormat\n\n```reason\n// And based lists (default, #type = #conjunction) in Swedish\nlet data =\n  Intl.ListFormat.make([\"Cat\", \"Tiger\", \"Lion\"], ~locale=Some(\"sv\"), ());\n// data: string = \"Cat, Tiger och Lion\"\n\n// Or based lists\nlet data =\n  Intl.ListFormat.make([\"Cat\", \"Tiger\", \"Lion\"],\n  ~options=Options.make(~type_=Some(#disjunction), ()), ());\n// data: string = \"Cat, Tiger, or Lion\"\n\n// Unit based lists\nlet data =\n  Intl.ListFormat.make([\"Cat\", \"Tiger\", \"Lion\"],\n  ~options=Options.make(~type_=Some(#unit), ()), ());\n// data: string = \"Cat, Tiger, Lion\"\n\nlet data =\n  Intl.ListFormat.make([\"Cat\", \"Tiger\", \"Lion\"],\n  ~options=Options.make(~type_=Some(#unit), ~style=Some(#narrow), ()), ());\n// data: string = \"Cat Tiger Lion\"\n```\n\n\nShort, `#short`, and narrow, `#narrow`, styles are [only available for `#unit` type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters). If you pass in any other type than `#unit` with those styles, the library takes care of it and changes the `type` to `#unit`.\n\n## Node\n\n**Node 13 added full ICU support and there should be no issues with wrong\nformatting.** If you need to\nrun a Node version before 13 it only has support for `en-US` locale by default. If your code is failing\nwith wrong formatting you'll need to install full locale support using:\n\n```\nnpm install -g full-icu\n```\n\nThe installer will print out what you need to set the environment variable `NODE_ICU_DATA` to in order to get full support.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopendevtools%2Frescript-intl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopendevtools%2Frescript-intl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopendevtools%2Frescript-intl/lists"}