{"id":17179529,"url":"https://github.com/cquiroz/scala-java-locales","last_synced_at":"2025-04-05T19:13:32.344Z","repository":{"id":8971762,"uuid":"58408347","full_name":"cquiroz/scala-java-locales","owner":"cquiroz","description":"Implementation of java locale for scala.js","archived":false,"fork":false,"pushed_at":"2025-03-17T15:58:21.000Z","size":1214,"stargazers_count":47,"open_issues_count":20,"forks_count":26,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-29T16:06:10.185Z","etag":null,"topics":["cldr","java-api","java-locale","scala","scala-js","scalajs"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cquiroz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-09T21:08:57.000Z","updated_at":"2025-03-17T15:58:27.000Z","dependencies_parsed_at":"2023-02-16T20:31:50.110Z","dependency_job_id":"cea4e2bb-59ea-44e1-970e-82c69da30bf8","html_url":"https://github.com/cquiroz/scala-java-locales","commit_stats":{"total_commits":565,"total_committers":16,"mean_commits":35.3125,"dds":0.6265486725663717,"last_synced_commit":"18f441288adfad19469cfab4f111e567852e305f"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cquiroz%2Fscala-java-locales","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cquiroz%2Fscala-java-locales/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cquiroz%2Fscala-java-locales/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cquiroz%2Fscala-java-locales/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cquiroz","download_url":"https://codeload.github.com/cquiroz/scala-java-locales/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386265,"owners_count":20930619,"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":["cldr","java-api","java-locale","scala","scala-js","scalajs"],"created_at":"2024-10-15T00:26:25.843Z","updated_at":"2025-04-05T19:13:32.328Z","avatar_url":"https://github.com/cquiroz.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scala-java-locales\n\n![build](https://github.com/cquiroz/scala-java-locales/workflows/build/badge.svg)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.cquiroz/scala-java-locales_sjs1_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.cquiroz/scala-java-locales_sjs1_2.13)\n[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.0.0.svg)](https://www.scala-js.org/)\n[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-0.6.29.svg)](https://www.scala-js.org/)\n\n`scala-java-locales` is a clean-room BSD-licensed implementation of the `java.util.Locale` API and related classes as defined on JDK8, mostly for Scala.js usage. It enables the locale API in Scala.js projects and supports usage requiring locales like number and dates formatting.\n\n## Usage\n\nSimply add the following line to your sbt settings:\n\n```scala\nlibraryDependencies += \"io.github.cquiroz\" %%% \"scala-java-locales\" % \"1.2.0\"\n```\n\nIf you have a `crossProject`, the setting must be used only in the JS part:\n\n```scala\nlazy val myCross = crossProject.\n  ...\n  .jsSettings(\n    libraryDependencies += \"io.github.cquiroz\" %%% \"scala-java-locales\" % \"1.2.0\"\n  )\n```\n\n**Requirement**: you must use a host JDK8 to _build_ your project, i.e., to\nlaunch sbt. `scala-java-locales` does not work on earlier JDKs.\n\n## Work in Progress / linking errors\n\nThis library is a work in progress and there are some unimplemented methods. If you use any of those on your Scala.js code, you will get linking errors.\n\n## Usage\n\nThe API follows the Java API for Locales, any major difference should be considered a bug.\n\nThe JVM includes a large locales database derived from CLDR. That includes things like date\nformats, region names, etc.\nHaving the full db on js is possible but expensive in terms of space and for most applications\nonly a few locales are needed, thus it is simpler to have a subset of them using some of the\nprovided locale dbs or even better via [sbt-locales](http://github.com/cquiroz/sbt-locales)\n`sbt-locales` lets you build a custom db with the minimal amount you need. There is a slight\nsize benefit and a larger speed improvement doing so as scala.js has less code to optimize\n\nFor the common cases that you just need date formatting in angling you can just include\n\n```scala\nlibraryDependencies += \"io.github.cquiroz\" %%% \"locales-minimal-en-db\" % \"1.2.0\"\n```\n\n## Default Locale\n\nStarting on 0.6.0 it is no longer necessary to register locales but only a minimal locale based on English is\nprovided. You may want to use [sbt-locales](https://github.com/cquiroz/sbt-locales) to generate\na custom locale database.\n\nFor example see:\n[gemini-locales](https://github.com/gemini-hlsw/gemini-locales/)\n\nIt is highly recommended to set your default Locale at the start of your application\n```\nLocale.setDefault(Locale.forLanguageTag(\u003cmy-locale\u003e))\n```\nThe Java API requires a default `Locale` though it doesn't mandate a specific one, instead, the runtime should select it depending on the platform.\n\nWhile the Java Locales use the OS default locale, on `Scala.js` platforms like browsers or node.js, it is harder to identify the default locale . `scala-java-locales` will try to guess the locale but if it can't or it is not not the locales db it sets `en (English)` as the default locale. This is a design decision to support the many API calls that require a default locale. It seems that `Scala.js` _de facto_ uses `en` for number formatting.\n\n## CLDR\n\n`java.util.Locale` is a relatively simple class and by itself it doesn't provide too much functionality. The key for its usefulness is on providing data about the locale especially in terms of classes like `java.text.DecimalFormatSymbols`, `java.text.DateFormatSymbols`, etc. The [Unicode CLDR](http://cldr.unicode.org/) project is a large repository of locale data that can be used to build the supporting classes, e.g. to get the `DecimalFormatSymbols` for a given locale.\n\nStarting on Java 8, [CLDR](https://docs.oracle.com/javase/8/docs/technotes/guides/intl/enhancements.8.html#cldr) is also used by the JVM, for comparisons the java flag `-Djava.locale.providers=CLDR` should be set.\n\n**Note:** Java 8 ships with an older CLDR version, specifically version 21. `scala-java-locales` uses the latest available version, hence there are some differences between the results and there are new available locales in `scala-java-locales`.\n\n## Disclaimer\n\nLocales and the CLDR specifications are vast subjects. The locales in this project are as good as the data and the interpretation of the specification is. While the data and implementation has been tested as much as possible, it is possible and likely that there are errors. Please post an issue or submit a PR if you find such errors.\n\nIn general the API attempts to behave be as close as possible to what happens on the JVM, e.g. the numeric system in Java seems to default to `latn` unless explicitly requested on the locale name.\n\n## Demo\nA very simple `Scala.js` project is available at [demo](demo)\n\n## Dependencies\n\n`scala-java-locales` explicitly doesn't have any dependencies.\n\n## Contributors\n\n+ Eric Peters [@er1c](https://github.com/er1c)\n+ A. Alonso Dominguez [@alonsodomin](https://github.com/alonsodomin)\n+ Marius B. Kotsbak [@mkotsbak](https://github.com/mkotsbak)\n+ Timothy Klim [@TimothyKlim](https://github.com/TimothyKlim)\n+ Andrea Peruffo [@andreaTP](https://github.com/AndreaTP)\n+ Olli Helenius [@liff](https://github.com/liff)\n\n## License\n\nCopyright \u0026copy; 2020 Carlos Quiroz\n\n`scala-java-locales` is distributed under the\n[BSD 3-Clause license](./LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcquiroz%2Fscala-java-locales","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcquiroz%2Fscala-java-locales","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcquiroz%2Fscala-java-locales/lists"}