Skip to content

Commit

Permalink
Add a fallback provider
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Quiroz <[email protected]>
  • Loading branch information
cquiroz committed Mar 2, 2020
1 parent 32c7fe8 commit 2aaa1c0
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 6 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release:
* First Change
* Second Change
draft: false
prerelease: false
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015-2016 Carlos Quiroz
Copyright (c) 2015-2020 Carlos Quiroz

All rights reserved.

Expand Down Expand Up @@ -66,4 +66,4 @@ copyright holder.

Unicode and the Unicode logo are trademarks of Unicode, Inc. in the United
States and other countries. All third party trademarks referenced herein are
the property of their respective owners.
the property of their respective owners.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ A very simple `Scala.js` project is available at [scalajs-locales-demo](https://

## License

Copyright &copy; 2019 Carlos Quiroz
Copyright &copy; 2020 Carlos Quiroz

`scala-java-locales` is distributed under the
[BSD 3-Clause license](./LICENSE.txt).
8 changes: 5 additions & 3 deletions core/src/main/scala/java/util/Locale.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ private[java] object LocalesDb {
val provider: LocalesProvider =
Reflect
.lookupLoadableModuleClass("locales.cldr.data.LocalesProvider$", null)
.getOrElse(sys.error("Needs a locale provider"))
.loadModule
.asInstanceOf[LocalesProvider]
.map { m =>
m.loadModule
.asInstanceOf[LocalesProvider]
}
.getOrElse(locales.cldr.fallback.LocalesProvider)

val root: LDML = provider.root

Expand Down
120 changes: 120 additions & 0 deletions core/src/main/scala/locales/cldr/fallback/data/data.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package locales.cldr.fallback.data

import locales.cldr._
import locales.cldr.fallback.data.numericsystems.latn

object _en
extends LDML(Some(_root),
LDMLLocale("en", None, None, None),
None,
List(
Symbols(latn,
None,
Some('.'),
Some(','),
Some(';'),
Some('%'),
Some('-'),
Some('‰'),
Some(""),
Some("NaN"),
Some("E"))
),
Some(
CalendarSymbols(
List("January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"),
List("Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"),
List("Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"),
List("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"),
List("AM", "PM"),
List("BC", "AD")
)
),
Some(
CalendarPatterns(
Map((0, "EEEE, MMMM d, y"), (1, "MMMM d, y"), (2, "MMM d, y"), (3, "M/d/yy")),
Map((0, "h:mm:ss a zzzz"), (1, "h:mm:ss a z"), (2, "h:mm:ss a"), (3, "h:mm a"))
)
),
List(),
NumberPatterns(Some("#,##0.###"), Some("#,##0%"), Some("¤#,##0.00;(¤#,##0.00)")))

object _root
extends LDML(None,
LDMLLocale("root", None, None, None),
Some(latn),
List(
Symbols(latn,
None,
Some('.'),
Some(','),
Some(';'),
Some('%'),
Some('-'),
Some('‰'),
Some(""),
Some("NaN"),
Some("E"))
),
Some(
CalendarSymbols(
List("M01",
"M02",
"M03",
"M04",
"M05",
"M06",
"M07",
"M08",
"M09",
"M10",
"M11",
"M12"),
List(),
List("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"),
List(),
List(),
List("BCE", "CE")
)
),
Some(
CalendarPatterns(
Map((0, "y MMMM d, EEEE"), (1, "y MMMM d"), (2, "y MMM d"), (3, "y-MM-dd")),
Map((0, "HH:mm:ss zzzz"), (1, "HH:mm:ss z"), (2, "HH:mm:ss"), (3, "HH:mm"))
)
),
List(),
NumberPatterns(Some("#,##0.###"), Some("#,##0%"), Some("¤ #,##0.00")))

object _all_ {
lazy val all: Array[LDML] = // Auto-generated code from CLDR definitions, don't edit
Array(_en, _root)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package locales.cldr.fallback.data

// Auto-generated code from CLDR definitions, don't edit
import locales.cldr.NumberingSystem
object numericsystems {
lazy val latn: NumberingSystem =
NumberingSystem("latn", List('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))
}
21 changes: 21 additions & 0 deletions core/src/main/scala/locales/cldr/fallback/ldmlprovider.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package locales.cldr.fallback

import locales.cldr._

object LocalesProvider extends LocalesProvider {
def root: LDML = data._root
def ldmls: Map[String, LDML] =
data._all_.all.map {
case l => (l.languageTag, l)
}.toMap
def latn: NumberingSystem = data.numericsystems.latn
def currencyData: CurrencyData =
new CurrencyData(
Seq.empty,
Seq.empty,
Seq.empty,
Seq.empty
)
def metadata: CLDRMetadata =
new CLDRMetadata(Array.empty, Map.empty, Array.empty, Map.empty, Array.empty)
}

0 comments on commit 2aaa1c0

Please sign in to comment.