Set up build infrastructure for fluent-ergonomics

This commit is contained in:
Savanni D'Gerinel 2022-12-31 12:39:11 -05:00
parent d0b376fe76
commit 954ea94bb2
8 changed files with 14 additions and 111 deletions

View File

@ -1 +0,0 @@
use flake

View File

@ -1,2 +0,0 @@
target
.direnv

View File

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "fluent" name = "fluent"
version = "0.15.0" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc4d7142005e2066e4844caf9f271b93fc79836ee96ec85057b8c109687e629a" checksum = "61f69378194459db76abd2ce3952b790db103ceb003008d3d50d97c41ff847a7"
dependencies = [ dependencies = [
"fluent-bundle", "fluent-bundle",
"unic-langid", "unic-langid",

View File

@ -18,6 +18,6 @@ include = [
] ]
[dependencies] [dependencies]
fluent = "0.15" fluent = "0.16"
unic-langid = "0.9" unic-langid = "0.9"
fluent-syntax = "0.11" fluent-syntax = "0.11"

View File

@ -0,0 +1,9 @@
dev:
cargo watch -x build
test:
cargo watch -x test
test-once:
cargo test

View File

@ -1,73 +0,0 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1637014545,
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1650400979,
"narHash": "sha256-OjWH2+HyxOwiO2jP01E1QH06gArw+zLWbCQMgEve9gg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "147b03fa8ebf9d5d5f6784f87dc61f0e7beee911",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-21.11",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1637453606,
"narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8afc4e543663ca0a6a4f496262cd05233737e732",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"oxalica": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"narHash": "sha256-lW3mZGsH0WYPI+zr/CzbDoWvRliYEHDT906yRx6NboY=",
"type": "tarball",
"url": "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"oxalica": "oxalica"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,30 +0,0 @@
{
description = "fluent-ergonomics";
inputs = {
nixpkgs.url = "nixpkgs/nixos-21.11";
oxalica.url = "https://github.com/oxalica/rust-overlay/archive/master.tar.gz";
};
outputs = { self, nixpkgs, oxalica }:
let
version = builtins.string 0 8 self.lastModifiedDate;
supportedSystems = [ "x86_64-linux" ];
in
{
devShell."x86_64-linux" =
let
rust_overlay = import oxalica;
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ rust_overlay ]; };
rust = pkgs.rust-bin.stable."1.59.0".default.override {
extensions = [ "rust-src" ];
};
in
pkgs.mkShell {
name = "fluent-ergonomics";
buildInputs = [
rust
];
};
};
}

View File

@ -331,7 +331,7 @@ history = Historio
.add_from_text(en_id, String::from(EN_TRANSLATIONS)) .add_from_text(en_id, String::from(EN_TRANSLATIONS))
.expect("text should load"); .expect("text should load");
let mut args = FluentArgs::new(); let mut args = FluentArgs::new();
args.insert("time", FluentValue::from(String::from("13:00"))); args.set("time", FluentValue::from(String::from("13:00")));
assert_eq!( assert_eq!(
fluent.tr("time_display", Some(&args)).unwrap(), fluent.tr("time_display", Some(&args)).unwrap(),
String::from("13:00 during the day") String::from("13:00 during the day")
@ -346,7 +346,7 @@ history = Historio
.add_from_text(en_id, String::from(EN_TRANSLATIONS)) .add_from_text(en_id, String::from(EN_TRANSLATIONS))
.expect("text should load"); .expect("text should load");
let mut args = FluentArgs::new(); let mut args = FluentArgs::new();
args.insert("time", FluentValue::from(String::from("13:00"))); args.set("time", FluentValue::from(String::from("13:00")));
assert_eq!( assert_eq!(
fluent.tr("nested_display", Some(&args)).unwrap(), fluent.tr("nested_display", Some(&args)).unwrap(),
String::from("nesting a time display: 13:00 during the day") String::from("nesting a time display: 13:00 during the day")