update to latest fluent libs, and integrate maximum digit handling

We now limit number of digits in our formatter, instead of relying
on an upstream patch.
This commit is contained in:
Damien Elmes 2020-11-03 14:02:05 +10:00
parent ef79596c5b
commit 3c12cb1600
19 changed files with 292 additions and 250 deletions

View file

@ -95,7 +95,7 @@ alias(
alias(
name = "fluent",
actual = "@raze__fluent__0_10_2//:fluent",
actual = "@raze__fluent__0_13_1//:fluent",
tags = [
"cargo-raze",
"manual",
@ -104,7 +104,7 @@ alias(
alias(
name = "fluent_syntax",
actual = "@raze__fluent_syntax__0_9_3//:fluent_syntax",
actual = "@raze__fluent_syntax__0_10_0//:fluent_syntax",
tags = [
"cargo-raze",
"manual",
@ -140,7 +140,7 @@ alias(
alias(
name = "intl_memoizer",
actual = "@raze__intl_memoizer__0_3_0//:intl_memoizer",
actual = "@raze__intl_memoizer__0_5_0//:intl_memoizer",
tags = [
"cargo-raze",
"manual",
@ -410,7 +410,7 @@ alias(
alias(
name = "unic_langid",
actual = "@raze__unic_langid__0_8_0//:unic_langid",
actual = "@raze__unic_langid__0_9_0//:unic_langid",
tags = [
"cargo-raze",
"manual",

43
cargo/Cargo.lock generated
View file

@ -532,8 +532,9 @@ dependencies = [
[[package]]
name = "fluent"
version = "0.10.2"
source = "git+https://github.com/ankitects/fluent-rs.git?branch=32bit-panic#f61c5e10a53161ef5261f3c87b62047f12e4aa74"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef9e54ec7b674ae3477d948ae790e90ae24d54fb31c2e7173252978d9b09bdfa"
dependencies = [
"fluent-bundle",
"unic-langid",
@ -541,8 +542,9 @@ dependencies = [
[[package]]
name = "fluent-bundle"
version = "0.10.2"
source = "git+https://github.com/ankitects/fluent-rs.git?branch=32bit-panic#f61c5e10a53161ef5261f3c87b62047f12e4aa74"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a79916560098f0a57215a489e37b7fc83088949eab7f7977dcc329b254d50c17"
dependencies = [
"fluent-langneg",
"fluent-syntax",
@ -555,18 +557,18 @@ dependencies = [
[[package]]
name = "fluent-langneg"
version = "0.12.1"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5815efd5542e40841cd34ef9003822352b04c67a70c595c6758597c72e1f56"
checksum = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94"
dependencies = [
"unic-langid",
]
[[package]]
name = "fluent-syntax"
version = "0.9.3"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac0f7e83d14cccbf26e165d8881dcac5891af0d85a88543c09dd72ebd31d91ba"
checksum = "9389354f858e38f37d9a249133611a1fcaec469f44773b04ddbd82f4f08d49eb"
[[package]]
name = "fnv"
@ -951,8 +953,9 @@ dependencies = [
[[package]]
name = "intl-memoizer"
version = "0.3.0"
source = "git+https://github.com/ankitects/fluent-rs.git?branch=32bit-panic#f61c5e10a53161ef5261f3c87b62047f12e4aa74"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a0ed58ba6089d49f8a9a7d5e16fc9b9e2019cdf40ef270f3d465fa244d9630b"
dependencies = [
"type-map",
"unic-langid",
@ -960,9 +963,9 @@ dependencies = [
[[package]]
name = "intl_pluralrules"
version = "6.0.0"
version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82c14d8eece42c03353e0ce86a4d3f97b1f1cef401e4d962dca6c6214a85002"
checksum = "6c271cdb1f12a9feb3a017619c3ee681f971f270f6757341d6abe1f9f7a98bc3"
dependencies = [
"tinystr",
"unic-langid",
@ -2266,9 +2269,9 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
[[package]]
name = "unic-langid"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d81136159f779c35b10655f45210c71cd5ca5a45aadfe9840a61c7071735ed"
checksum = "73328fcd730a030bdb19ddf23e192187a6b01cd98be6d3140622a89129459ce5"
dependencies = [
"unic-langid-impl",
"unic-langid-macros",
@ -2276,18 +2279,18 @@ dependencies = [
[[package]]
name = "unic-langid-impl"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c43c61e94492eb67f20facc7b025778a904de83d953d8fcb60dd9adfd6e2d0ea"
checksum = "1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d"
dependencies = [
"tinystr",
]
[[package]]
name = "unic-langid-macros"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49bd90791278634d57e3ed4a4073108e3f79bfb87ab6a7b8664ba097425703df"
checksum = "18f980d6d87e8805f2836d64b4138cc95aa7986fa63b1f51f67d5fbff64dd6e5"
dependencies = [
"proc-macro-hack",
"tinystr",
@ -2297,9 +2300,9 @@ dependencies = [
[[package]]
name = "unic-langid-macros-impl"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0098f77bd754f8fb7850cdf4ab143aa821898c4ac6dc16bcb2aa3e62ce858d1"
checksum = "29396ffd97e27574c3e01368b1a64267d3064969e4848e2e130ff668be9daa9f"
dependencies = [
"proc-macro-hack",
"quote",

View file

@ -552,41 +552,43 @@ def raze_fetch_remote_crates():
)
maybe(
new_git_repository,
name = "raze__fluent__0_10_2",
remote = "https://github.com/ankitects/fluent-rs.git",
commit = "f61c5e10a53161ef5261f3c87b62047f12e4aa74",
build_file = Label("//cargo/remote:fluent-0.10.2.BUILD.bazel"),
init_submodules = True,
)
maybe(
new_git_repository,
name = "raze__fluent_bundle__0_10_2",
remote = "https://github.com/ankitects/fluent-rs.git",
commit = "f61c5e10a53161ef5261f3c87b62047f12e4aa74",
build_file = Label("//cargo/remote:fluent-bundle-0.10.2.BUILD.bazel"),
init_submodules = True,
http_archive,
name = "raze__fluent__0_13_1",
url = "https://crates.io/api/v1/crates/fluent/0.13.1/download",
type = "tar.gz",
sha256 = "ef9e54ec7b674ae3477d948ae790e90ae24d54fb31c2e7173252978d9b09bdfa",
strip_prefix = "fluent-0.13.1",
build_file = Label("//cargo/remote:fluent-0.13.1.BUILD.bazel"),
)
maybe(
http_archive,
name = "raze__fluent_langneg__0_12_1",
url = "https://crates.io/api/v1/crates/fluent-langneg/0.12.1/download",
name = "raze__fluent_bundle__0_13_1",
url = "https://crates.io/api/v1/crates/fluent-bundle/0.13.1/download",
type = "tar.gz",
sha256 = "fe5815efd5542e40841cd34ef9003822352b04c67a70c595c6758597c72e1f56",
strip_prefix = "fluent-langneg-0.12.1",
build_file = Label("//cargo/remote:fluent-langneg-0.12.1.BUILD.bazel"),
sha256 = "a79916560098f0a57215a489e37b7fc83088949eab7f7977dcc329b254d50c17",
strip_prefix = "fluent-bundle-0.13.1",
build_file = Label("//cargo/remote:fluent-bundle-0.13.1.BUILD.bazel"),
)
maybe(
http_archive,
name = "raze__fluent_syntax__0_9_3",
url = "https://crates.io/api/v1/crates/fluent-syntax/0.9.3/download",
name = "raze__fluent_langneg__0_13_0",
url = "https://crates.io/api/v1/crates/fluent-langneg/0.13.0/download",
type = "tar.gz",
sha256 = "ac0f7e83d14cccbf26e165d8881dcac5891af0d85a88543c09dd72ebd31d91ba",
strip_prefix = "fluent-syntax-0.9.3",
build_file = Label("//cargo/remote:fluent-syntax-0.9.3.BUILD.bazel"),
sha256 = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94",
strip_prefix = "fluent-langneg-0.13.0",
build_file = Label("//cargo/remote:fluent-langneg-0.13.0.BUILD.bazel"),
)
maybe(
http_archive,
name = "raze__fluent_syntax__0_10_0",
url = "https://crates.io/api/v1/crates/fluent-syntax/0.10.0/download",
type = "tar.gz",
sha256 = "9389354f858e38f37d9a249133611a1fcaec469f44773b04ddbd82f4f08d49eb",
strip_prefix = "fluent-syntax-0.10.0",
build_file = Label("//cargo/remote:fluent-syntax-0.10.0.BUILD.bazel"),
)
maybe(
@ -970,22 +972,23 @@ def raze_fetch_remote_crates():
)
maybe(
new_git_repository,
name = "raze__intl_memoizer__0_3_0",
remote = "https://github.com/ankitects/fluent-rs.git",
commit = "f61c5e10a53161ef5261f3c87b62047f12e4aa74",
build_file = Label("//cargo/remote:intl-memoizer-0.3.0.BUILD.bazel"),
init_submodules = True,
http_archive,
name = "raze__intl_memoizer__0_5_0",
url = "https://crates.io/api/v1/crates/intl-memoizer/0.5.0/download",
type = "tar.gz",
sha256 = "8a0ed58ba6089d49f8a9a7d5e16fc9b9e2019cdf40ef270f3d465fa244d9630b",
strip_prefix = "intl-memoizer-0.5.0",
build_file = Label("//cargo/remote:intl-memoizer-0.5.0.BUILD.bazel"),
)
maybe(
http_archive,
name = "raze__intl_pluralrules__6_0_0",
url = "https://crates.io/api/v1/crates/intl_pluralrules/6.0.0/download",
name = "raze__intl_pluralrules__7_0_0",
url = "https://crates.io/api/v1/crates/intl_pluralrules/7.0.0/download",
type = "tar.gz",
sha256 = "d82c14d8eece42c03353e0ce86a4d3f97b1f1cef401e4d962dca6c6214a85002",
strip_prefix = "intl_pluralrules-6.0.0",
build_file = Label("//cargo/remote:intl_pluralrules-6.0.0.BUILD.bazel"),
sha256 = "6c271cdb1f12a9feb3a017619c3ee681f971f270f6757341d6abe1f9f7a98bc3",
strip_prefix = "intl_pluralrules-7.0.0",
build_file = Label("//cargo/remote:intl_pluralrules-7.0.0.BUILD.bazel"),
)
maybe(
@ -2320,42 +2323,42 @@ def raze_fetch_remote_crates():
maybe(
http_archive,
name = "raze__unic_langid__0_8_0",
url = "https://crates.io/api/v1/crates/unic-langid/0.8.0/download",
name = "raze__unic_langid__0_9_0",
url = "https://crates.io/api/v1/crates/unic-langid/0.9.0/download",
type = "tar.gz",
sha256 = "24d81136159f779c35b10655f45210c71cd5ca5a45aadfe9840a61c7071735ed",
strip_prefix = "unic-langid-0.8.0",
build_file = Label("//cargo/remote:unic-langid-0.8.0.BUILD.bazel"),
sha256 = "73328fcd730a030bdb19ddf23e192187a6b01cd98be6d3140622a89129459ce5",
strip_prefix = "unic-langid-0.9.0",
build_file = Label("//cargo/remote:unic-langid-0.9.0.BUILD.bazel"),
)
maybe(
http_archive,
name = "raze__unic_langid_impl__0_8_0",
url = "https://crates.io/api/v1/crates/unic-langid-impl/0.8.0/download",
name = "raze__unic_langid_impl__0_9_0",
url = "https://crates.io/api/v1/crates/unic-langid-impl/0.9.0/download",
type = "tar.gz",
sha256 = "c43c61e94492eb67f20facc7b025778a904de83d953d8fcb60dd9adfd6e2d0ea",
strip_prefix = "unic-langid-impl-0.8.0",
build_file = Label("//cargo/remote:unic-langid-impl-0.8.0.BUILD.bazel"),
sha256 = "1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d",
strip_prefix = "unic-langid-impl-0.9.0",
build_file = Label("//cargo/remote:unic-langid-impl-0.9.0.BUILD.bazel"),
)
maybe(
http_archive,
name = "raze__unic_langid_macros__0_8_0",
url = "https://crates.io/api/v1/crates/unic-langid-macros/0.8.0/download",
name = "raze__unic_langid_macros__0_9_0",
url = "https://crates.io/api/v1/crates/unic-langid-macros/0.9.0/download",
type = "tar.gz",
sha256 = "49bd90791278634d57e3ed4a4073108e3f79bfb87ab6a7b8664ba097425703df",
strip_prefix = "unic-langid-macros-0.8.0",
build_file = Label("//cargo/remote:unic-langid-macros-0.8.0.BUILD.bazel"),
sha256 = "18f980d6d87e8805f2836d64b4138cc95aa7986fa63b1f51f67d5fbff64dd6e5",
strip_prefix = "unic-langid-macros-0.9.0",
build_file = Label("//cargo/remote:unic-langid-macros-0.9.0.BUILD.bazel"),
)
maybe(
http_archive,
name = "raze__unic_langid_macros_impl__0_8_0",
url = "https://crates.io/api/v1/crates/unic-langid-macros-impl/0.8.0/download",
name = "raze__unic_langid_macros_impl__0_9_0",
url = "https://crates.io/api/v1/crates/unic-langid-macros-impl/0.9.0/download",
type = "tar.gz",
sha256 = "e0098f77bd754f8fb7850cdf4ab143aa821898c4ac6dc16bcb2aa3e62ce858d1",
strip_prefix = "unic-langid-macros-impl-0.8.0",
build_file = Label("//cargo/remote:unic-langid-macros-impl-0.8.0.BUILD.bazel"),
sha256 = "29396ffd97e27574c3e01368b1a64267d3064969e4848e2e130ff668be9daa9f",
strip_prefix = "unic-langid-macros-impl-0.9.0",
build_file = Label("//cargo/remote:unic-langid-macros-impl-0.9.0.BUILD.bazel"),
)
maybe(

View file

@ -35,16 +35,16 @@ rust_library(
name = "fluent",
crate_type = "lib",
deps = [
"@raze__fluent_bundle__0_10_2//:fluent_bundle",
"@raze__unic_langid__0_8_0//:unic_langid",
"@raze__fluent_bundle__0_13_1//:fluent_bundle",
"@raze__unic_langid__0_9_0//:unic_langid",
],
srcs = glob(["**/*.rs"]),
crate_root = "fluent/src/lib.rs",
crate_root = "src/lib.rs",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
version = "0.10.2",
version = "0.13.1",
tags = [
"cargo-raze",
"manual",
@ -52,5 +52,3 @@ rust_library(
crate_features = [
],
)
# Unsupported target "macro" with type "test" omitted
# Unsupported target "pseudo" with type "test" omitted

View file

@ -1,72 +0,0 @@
"""
@generated
cargo-raze crate build file.
DO NOT EDIT! Replaced on runs of cargo-raze
"""
# buildifier: disable=load
load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_binary",
"rust_library",
"rust_test",
)
# buildifier: disable=load
load("@bazel_skylib//lib:selects.bzl", "selects")
package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])
licenses([
"notice", # Apache-2.0 from expression "Apache-2.0 OR MIT"
])
# Generated targets
# Unsupported target "bundle" with type "test" omitted
# Unsupported target "custom_formatter" with type "example" omitted
# Unsupported target "custom_type" with type "example" omitted
# Unsupported target "custom_types" with type "test" omitted
# Unsupported target "external_arguments" with type "example" omitted
# buildifier: leave-alone
rust_library(
name = "fluent_bundle",
crate_type = "lib",
deps = [
"@raze__fluent_langneg__0_12_1//:fluent_langneg",
"@raze__fluent_syntax__0_9_3//:fluent_syntax",
"@raze__intl_memoizer__0_3_0//:intl_memoizer",
"@raze__intl_pluralrules__6_0_0//:intl_pluralrules",
"@raze__rental__0_5_5//:rental",
"@raze__smallvec__1_4_2//:smallvec",
"@raze__unic_langid__0_8_0//:unic_langid",
],
srcs = glob(["**/*.rs"]),
crate_root = "fluent-bundle/src/lib.rs",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
version = "0.10.2",
tags = [
"cargo-raze",
"manual",
],
crate_features = [
],
)
# Unsupported target "functions" with type "example" omitted
# Unsupported target "hello" with type "example" omitted
# Unsupported target "message_reference" with type "example" omitted
# Unsupported target "resolver" with type "bench" omitted
# Unsupported target "resolver_fixtures" with type "test" omitted
# Unsupported target "selector" with type "example" omitted
# Unsupported target "simple-app" with type "example" omitted
# Unsupported target "types_test" with type "test" omitted

View file

@ -0,0 +1,60 @@
"""
@generated
cargo-raze crate build file.
DO NOT EDIT! Replaced on runs of cargo-raze
"""
# buildifier: disable=load
load(
"@io_bazel_rules_rust//rust:rust.bzl",
"rust_binary",
"rust_library",
"rust_test",
)
# buildifier: disable=load
load("@bazel_skylib//lib:selects.bzl", "selects")
package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])
licenses([
"notice", # Apache-2.0 from expression "Apache-2.0 OR MIT"
])
# Generated targets
# buildifier: leave-alone
rust_library(
name = "fluent_bundle",
crate_type = "lib",
deps = [
"@raze__fluent_langneg__0_13_0//:fluent_langneg",
"@raze__fluent_syntax__0_10_0//:fluent_syntax",
"@raze__intl_memoizer__0_5_0//:intl_memoizer",
"@raze__intl_pluralrules__7_0_0//:intl_pluralrules",
"@raze__rental__0_5_5//:rental",
"@raze__smallvec__1_4_2//:smallvec",
"@raze__unic_langid__0_9_0//:unic_langid",
],
srcs = glob(["**/*.rs"]),
crate_root = "src/lib.rs",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
version = "0.13.1",
tags = [
"cargo-raze",
"manual",
],
crate_features = [
],
)
# Unsupported target "resolver" with type "bench" omitted

View file

@ -35,7 +35,7 @@ rust_library(
name = "fluent_langneg",
crate_type = "lib",
deps = [
"@raze__unic_langid__0_8_0//:unic_langid",
"@raze__unic_langid__0_9_0//:unic_langid",
],
srcs = glob(["**/*.rs"]),
crate_root = "src/lib.rs",
@ -43,7 +43,7 @@ rust_library(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.12.1",
version = "0.13.0",
tags = [
"cargo-raze",
"manual",
@ -52,6 +52,4 @@ rust_library(
"default",
],
)
# Unsupported target "lib" with type "test" omitted
# Unsupported target "negotiate" with type "bench" omitted
# Unsupported target "negotiate" with type "example" omitted

View file

@ -42,7 +42,7 @@ rust_library(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.9.3",
version = "0.10.0",
tags = [
"cargo-raze",
"manual",
@ -68,7 +68,7 @@ rust_binary(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.9.3",
version = "0.10.0",
tags = [
"cargo-raze",
"manual",
@ -78,4 +78,28 @@ rust_binary(
],
)
# Unsupported target "parser_fixtures" with type "test" omitted
# Unsupported target "unicode" with type "test" omitted
# buildifier: leave-alone
rust_binary(
# Prefix bin name to disambiguate from (probable) collision with lib name
# N.B.: The exact form of this is subject to change.
name = "cargo_bin_update_fixtures",
deps = [
# Binaries get an implicit dependency on their crate's lib
":fluent_syntax",
],
srcs = glob(["**/*.rs"]),
crate_root = "src/bin/update_fixtures.rs",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
version = "0.10.0",
tags = [
"cargo-raze",
"manual",
],
crate_features = [
"default",
],
)

View file

@ -36,15 +36,15 @@ rust_library(
crate_type = "lib",
deps = [
"@raze__type_map__0_3_0//:type_map",
"@raze__unic_langid__0_8_0//:unic_langid",
"@raze__unic_langid__0_9_0//:unic_langid",
],
srcs = glob(["**/*.rs"]),
crate_root = "intl-memoizer/src/lib.rs",
crate_root = "src/lib.rs",
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
version = "0.3.0",
version = "0.5.0",
tags = [
"cargo-raze",
"manual",
@ -52,5 +52,3 @@ rust_library(
crate_features = [
],
)
# Unsupported target "numberformat" with type "example" omitted
# Unsupported target "pluralrules" with type "example" omitted

View file

@ -36,7 +36,7 @@ rust_library(
crate_type = "lib",
deps = [
"@raze__tinystr__0_3_4//:tinystr",
"@raze__unic_langid__0_8_0//:unic_langid",
"@raze__unic_langid__0_9_0//:unic_langid",
],
srcs = glob(["**/*.rs"]),
crate_root = "src/lib.rs",
@ -44,7 +44,7 @@ rust_library(
rustc_flags = [
"--cap-lints=allow",
],
version = "6.0.0",
version = "7.0.0",
tags = [
"cargo-raze",
"manual",
@ -52,5 +52,4 @@ rust_library(
crate_features = [
],
)
# Unsupported target "operands" with type "test" omitted
# Unsupported target "pluralrules" with type "bench" omitted

View file

@ -29,16 +29,14 @@ licenses([
])
# Generated targets
# Unsupported target "langid" with type "test" omitted
# Unsupported target "simple-langid" with type "example" omitted
# buildifier: leave-alone
rust_library(
name = "unic_langid",
crate_type = "lib",
deps = [
"@raze__unic_langid_impl__0_8_0//:unic_langid_impl",
"@raze__unic_langid_macros__0_8_0//:unic_langid_macros",
"@raze__unic_langid_impl__0_9_0//:unic_langid_impl",
"@raze__unic_langid_macros__0_9_0//:unic_langid_macros",
],
srcs = glob(["**/*.rs"]),
crate_root = "src/lib.rs",
@ -46,7 +44,7 @@ rust_library(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.8.0",
version = "0.9.0",
tags = [
"cargo-raze",
"manual",

View file

@ -30,8 +30,6 @@ licenses([
# Generated targets
# Unsupported target "canonicalize" with type "bench" omitted
# Unsupported target "canonicalize_test" with type "test" omitted
# Unsupported target "fixtures" with type "test" omitted
# buildifier: leave-alone
rust_binary(
@ -49,7 +47,7 @@ rust_binary(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.8.0",
version = "0.9.0",
tags = [
"cargo-raze",
"manual",
@ -74,7 +72,7 @@ rust_binary(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.8.0",
version = "0.9.0",
tags = [
"cargo-raze",
"manual",
@ -83,7 +81,6 @@ rust_binary(
],
)
# Unsupported target "langid" with type "bench" omitted
# Unsupported target "language_identifier_test" with type "test" omitted
# Unsupported target "likely_subtags" with type "bench" omitted
# Unsupported target "likelysubtags" with type "test" omitted
# Unsupported target "parser" with type "bench" omitted
@ -101,7 +98,7 @@ rust_library(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.8.0",
version = "0.9.0",
tags = [
"cargo-raze",
"manual",

View file

@ -29,7 +29,6 @@ licenses([
])
# Generated targets
# Unsupported target "langid-macro" with type "example" omitted
# buildifier: leave-alone
rust_library(
@ -37,19 +36,19 @@ rust_library(
crate_type = "lib",
deps = [
"@raze__tinystr__0_3_4//:tinystr",
"@raze__unic_langid_impl__0_8_0//:unic_langid_impl",
"@raze__unic_langid_impl__0_9_0//:unic_langid_impl",
],
srcs = glob(["**/*.rs"]),
crate_root = "src/lib.rs",
edition = "2018",
proc_macro_deps = [
"@raze__proc_macro_hack__0_5_19//:proc_macro_hack",
"@raze__unic_langid_macros_impl__0_8_0//:unic_langid_macros_impl",
"@raze__unic_langid_macros_impl__0_9_0//:unic_langid_macros_impl",
],
rustc_flags = [
"--cap-lints=allow",
],
version = "0.8.0",
version = "0.9.0",
tags = [
"cargo-raze",
"manual",

View file

@ -37,7 +37,7 @@ rust_library(
deps = [
"@raze__quote__1_0_7//:quote",
"@raze__syn__1_0_48//:syn",
"@raze__unic_langid_impl__0_8_0//:unic_langid_impl",
"@raze__unic_langid_impl__0_9_0//:unic_langid_impl",
],
srcs = glob(["**/*.rs"]),
crate_root = "src/lib.rs",
@ -48,7 +48,7 @@ rust_library(
rustc_flags = [
"--cap-lints=allow",
],
version = "0.8.0",
version = "0.9.0",
tags = [
"cargo-raze",
"manual",

View file

@ -60,6 +60,7 @@ with open("Cargo.toml", "w") as file:
# update Cargo.lock
subprocess.run(["cargo", "update"], check=True)
input("hit enter to proceed")
# generate cargo-raze files
if os.path.exists("remote"):

View file

@ -17,7 +17,7 @@ path = "src/lib.rs"
######################
[build-dependencies]
fluent-syntax = "0.9.3"
fluent-syntax = "0.10"
prost-build = { git = "https://github.com/danburkert/prost.git", rev = "4ded4a98ef339da0b7babd4efee3fbe8adaf746b" }
[dev-dependencies]
@ -35,11 +35,13 @@ chrono = "0.4.13"
coarsetime = { git = "https://github.com/ankitects/rust-coarsetime.git", tag="anki-2020-11-03" }
failure = "0.1.8"
flate2 = "1.0.16"
fluent = { git = "https://github.com/ankitects/fluent-rs.git", branch="32bit-panic" }
fluent = "0.13.1"
#fluent = { git = "https://github.com/ankitects/fluent-rs.git", branch="32bit-panic" }
futures = "0.3.5"
hex = "0.4.2"
htmlescape = "0.3.1"
intl-memoizer = { git = "https://github.com/ankitects/fluent-rs.git", branch="32bit-panic" }
intl-memoizer = "0.5"
#intl-memoizer = { git = "https://github.com/ankitects/fluent-rs.git", branch="32bit-panic" }
itertools = "0.9.0"
lazy_static = "1.4.0"
nom = "5.1.2"
@ -67,7 +69,7 @@ slog-envlogger = "2.2.0"
slog-term = "2.6.0"
tempfile = "3.1.0"
tokio = { version = "0.2.21", features = ["fs", "rt-threaded"] }
unic-langid = { version = "0.8.0", features = ["macros"] }
unic-langid = { version = "0.9", features = ["macros"] }
unicode-normalization = "0.1.13"
utime = "0.3.1"
zip = { version = "0.5.6", default-features = false, features = ["deflate", "time"] }

View file

@ -1,15 +1,15 @@
use fluent_syntax::ast::{Entry::Message, ResourceEntry};
use fluent_syntax::parser::parse;
use fluent_syntax::ast::Entry;
use fluent_syntax::parser::Parser;
use std::collections::HashMap;
use std::path::Path;
use std::{fs, path::PathBuf};
fn get_identifiers(ftl_text: &str) -> Vec<String> {
let res = parse(ftl_text).unwrap();
let res = Parser::new(ftl_text).parse().unwrap();
let mut idents = vec![];
for entry in res.body {
if let ResourceEntry::Entry(Message(m)) = entry {
if let Entry::Message(m) = entry {
idents.push(m.id.name.to_string());
}
}

View file

@ -1 +0,0 @@
stable

View file

@ -3,8 +3,7 @@
use crate::err::Result;
use crate::log::{error, Logger};
use fluent::{FluentArgs, FluentBundle, FluentResource, FluentValue};
use intl_memoizer::IntlLangMemoizer;
use fluent::{concurrent::FluentBundle, FluentArgs, FluentResource, FluentValue};
use num_format::Locale;
use serde::Serialize;
use std::borrow::Cow;
@ -25,7 +24,7 @@ macro_rules! tr_strs {
{
let mut args: fluent::FluentArgs = fluent::FluentArgs::new();
$(
args.insert($key, $value.to_string().into());
args.add($key, $value.to_string().into());
)*
args
}
@ -39,13 +38,13 @@ pub use tr_strs;
/// If neither folder exists, return None.
fn lang_folder(lang: Option<&LanguageIdentifier>, ftl_folder: &Path) -> Option<PathBuf> {
if let Some(lang) = lang {
if let Some(region) = lang.region() {
let path = ftl_folder.join(format!("{}_{}", lang.language(), region));
if let Some(region) = lang.region {
let path = ftl_folder.join(format!("{}_{}", lang.language, region));
if fs::metadata(&path).is_ok() {
return Some(path);
}
}
let path = ftl_folder.join(lang.language());
let path = ftl_folder.join(lang.language.to_string());
if fs::metadata(&path).is_ok() {
Some(path)
} else {
@ -85,20 +84,24 @@ fn ftl_template_text() -> &'static str {
}
fn ftl_localized_text(lang: &LanguageIdentifier) -> Option<&'static str> {
Some(match lang.language() {
let region = match &lang.region {
Some(region) => Some(region.as_str()),
None => None,
};
Some(match lang.language.as_str() {
"en" => {
match lang.region() {
match region {
Some("GB") | Some("AU") => ftl_path!("en-GB.ftl"),
// use fallback language instead
_ => return None,
}
}
"zh" => match lang.region() {
"zh" => match region {
Some("TW") | Some("HK") => ftl_path!("zh-TW.ftl"),
_ => ftl_path!("zh-CN.ftl"),
},
"pt" => {
if let Some("PT") = lang.region() {
if let Some("PT") = region {
ftl_path!("pt-PT.ftl")
} else {
ftl_path!("pt-BR.ftl")
@ -259,7 +262,7 @@ fn get_bundle_with_extra(
None => {
extra_text += test_en_text();
}
Some(lang) if lang.language() == "ja" => {
Some(lang) if lang.language == "ja" => {
extra_text += test_jp_text();
}
_ => {}
@ -290,7 +293,7 @@ impl I18n {
let code = code.as_ref();
if let Ok(lang) = code.parse::<LanguageIdentifier>() {
langs.push(lang.clone());
if lang.language() == "en" {
if lang.language == "en" {
// if English was listed, any further preferences are skipped,
// as the template has 100% coverage, and we need to ensure
// it is tried prior to any other langs.
@ -310,7 +313,7 @@ impl I18n {
resource_text.push(text);
bundles.push(bundle);
} else {
error!(log, "Failed to create bundle for {:?}", lang.language())
error!(log, "Failed to create bundle for {:?}", lang.language)
}
}
}
@ -389,17 +392,13 @@ struct I18nInner {
resource_text: Vec<&'static str>,
}
// Simple number formatting implementation
fn set_bundle_formatter_for_langs<T>(bundle: &mut FluentBundle<T>, langs: &[LanguageIdentifier]) {
let num_formatter = NumberFormatter::new(langs);
let formatter = move |val: &FluentValue, _intls: &Mutex<IntlLangMemoizer>| -> Option<String> {
match val {
FluentValue::Number(n) => {
let mut num = n.clone();
num.options.maximum_fraction_digits = Some(2);
Some(num_formatter.format(num.as_string().to_string()))
}
_ => None,
}
let formatter = if want_comma_as_decimal_separator(langs) {
format_decimal_with_comma
} else {
format_decimal_with_period
};
bundle.set_formatter(Some(formatter));
@ -417,41 +416,78 @@ fn first_available_num_format_locale(langs: &[LanguageIdentifier]) -> Option<Loc
// try to locate a num_format locale for a given language identifier
fn num_format_locale(lang: &LanguageIdentifier) -> Option<Locale> {
// region provided?
if let Some(region) = lang.region() {
let code = format!("{}_{}", lang.language(), region);
if let Some(region) = lang.region {
let code = format!("{}_{}", lang.language, region);
if let Ok(locale) = Locale::from_name(code) {
return Some(locale);
}
}
// try the language alone
Locale::from_name(lang.language()).ok()
Locale::from_name(lang.language.as_str()).ok()
}
struct NumberFormatter {
decimal_separator: &'static str,
fn want_comma_as_decimal_separator(langs: &[LanguageIdentifier]) -> bool {
let separator = if let Some(locale) = first_available_num_format_locale(langs) {
locale.decimal()
} else {
"."
};
separator == ","
}
impl NumberFormatter {
fn new(langs: &[LanguageIdentifier]) -> Self {
if let Some(locale) = first_available_num_format_locale(langs) {
Self {
decimal_separator: locale.decimal(),
}
} else {
// fallback on English defaults
Self {
decimal_separator: ".",
}
}
}
fn format_decimal_with_comma(
val: &fluent::FluentValue,
_intl: &intl_memoizer::concurrent::IntlLangMemoizer,
) -> Option<String> {
format_number_values(val, Some(","))
}
/// Given a pre-formatted number, change the decimal separator as appropriate.
fn format(&self, num: String) -> String {
if self.decimal_separator != "." {
num.replace(".", self.decimal_separator)
} else {
num
fn format_decimal_with_period(
val: &fluent::FluentValue,
_intl: &intl_memoizer::concurrent::IntlLangMemoizer,
) -> Option<String> {
format_number_values(val, None)
}
#[inline]
fn format_number_values(
val: &fluent::FluentValue,
alt_separator: Option<&'static str>,
) -> Option<String> {
match val {
FluentValue::Number(num) => {
// create a string with desired maximum digits
let max_frac_digits = 2;
let with_max_precision = format!(
"{number:.precision$}",
number = num.value,
precision = max_frac_digits
);
// remove any excess trailing zeros
let mut val: Cow<str> = with_max_precision.trim_end_matches('0').into();
// adding back any required to meet minimum_fraction_digits
if let Some(minfd) = num.options.minimum_fraction_digits {
let pos = val.find('.').expect("expected . in formatted string");
let frac_num = val.len() - pos - 1;
let zeros_needed = minfd - frac_num;
if zeros_needed > 0 {
val = format!("{}{}", val, "0".repeat(zeros_needed)).into();
}
}
// lop off any trailing '.'
let result = val.trim_end_matches('.');
if let Some(sep) = alt_separator {
Some(result.replace('.', sep))
} else {
Some(result.to_string())
}
}
_ => None,
}
}
@ -463,16 +499,15 @@ pub struct ResourcesForJavascript {
#[cfg(test)]
mod test {
use crate::i18n::NumberFormatter;
use crate::i18n::{tr_args, I18n};
use super::*;
use crate::log;
use std::path::PathBuf;
use unic_langid::langid;
#[test]
fn numbers() {
let fmter = NumberFormatter::new(&[langid!("pl-PL")]);
assert_eq!(&fmter.format("1.007".to_string()), "1,007");
assert_eq!(want_comma_as_decimal_separator(&[langid!("en-US")]), false);
assert_eq!(want_comma_as_decimal_separator(&[langid!("pl-PL")]), true);
}
#[test]