Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ let out = convert(text, &catalog, &Locale::new("en-US"), &Locale::new("zh-CN"),
let identity = catalog.identity();
```

Note: settings-bearing programs cannot be parsed from raw text (a `.ws`
decompiler is a non-goal); settings are carried in WIR and emitted by the
library. Locale detection is available via `workshop_rs::detect`.
Settings-bearing programs are parsed into the canonical WIR settings carrier
and emitted by the library. Locale detection is available via
`workshop_rs::detect`.

## CLI usage

Expand Down Expand Up @@ -105,11 +105,20 @@ the canonical form with a fresh digest (byte-idempotent). See

## Locale status

* `en-US`: complete declared surface (344/344 canonical entries), corpus
* `en-US`: complete declared surface (341/341 canonical entries), corpus
round-trips and settings emission tested.
* `zh-CN`: declared as a locale with **zero mappings** pending a reviewed,
MIT-permissible reference source. Conversion into `zh-CN` fails explicitly
for every entry; no zh-CN compatibility claim is made.
* `zh-CN`: the reviewed export-backed corpus covers **341/341** canonical
entries (structural 11/11, actions 60/60, values 77/77, events 3/3,
operators 14/14, enum members 176/176). The declared surface is complete;
settings data covers labels 19/19 and all other declared settings sections.

The corpus is reproducible with the user-provided export (not committed):

```sh
cargo run -p workshop-rs --bin workshop-catalog-gen -- corpus \
--export /path/to/workshop-data.json
cargo run -p workshop-rs --bin workshop-catalog-gen -- build
```

## Validation

Expand All @@ -124,6 +133,6 @@ CI runs the same checks on stable and the pinned toolchain (1.85.0).

## License

MIT — see [LICENSE](LICENSE). Committed data carries recorded provenance
([docs/provenance.md](docs/provenance.md)); GPL reference data (e.g. OverPy
translation tables) is not a permissible data source.
MIT — see [LICENSE](LICENSE). Committed mapping data carries recorded
provenance ([docs/provenance.md](docs/provenance.md)); the user-provided JSON
is build input and is not redistributed.
31 changes: 20 additions & 11 deletions crates/workshop-rs-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ fn locales_lists_declared_locales_with_coverage() {
let stdout = String::from_utf8(output.stdout).unwrap();
let lines: Vec<&str> = stdout.lines().collect();
assert_eq!(lines.len(), 2);
assert!(lines[0].starts_with("en-us 344/344"), "{stdout}");
assert!(lines[1].starts_with("zh-cn 0/344"), "{stdout}");
assert!(lines[0].starts_with("en-us 341/341"), "{stdout}");
assert!(lines[1].starts_with("zh-cn 341/341"), "{stdout}");
}

#[test]
Expand Down Expand Up @@ -110,7 +110,7 @@ fn emit_emits_localized_text() {
}

#[test]
fn convert_to_zh_cn_fails_explicitly_without_fallback() {
fn convert_to_zh_cn_uses_the_corpus_without_fallback() {
let file = fixture("basic-rule");
let output = run(&[
"convert",
Expand All @@ -120,22 +120,29 @@ fn convert_to_zh_cn_fails_explicitly_without_fallback() {
"--to",
"zh-CN",
]);
assert_eq!(output.status.code(), Some(1));
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(stderr.contains("missing"), "{stderr}");
assert!(stderr.contains("zh-cn"), "{stderr}");
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("持续 - 全局"), "{stdout}");
assert!(stdout.contains("禁用查看器录制"), "{stdout}");
}

#[test]
fn convert_to_zh_cn_with_fallback_reports_the_choice() {
let file = fixture("basic-rule");
let dir = std::env::temp_dir().join("workshop-rs-cli-convert-fallback");
std::fs::create_dir_all(&dir).unwrap();
let file = dir.join("unmapped.ws");
std::fs::write(
&file,
"rule (\"setup\") { event { Ongoing - Global; } actions { Disable Inspector Recording; } }",
)
.unwrap();
let output = run(&[
"convert",
file.to_str().unwrap(),
"--from",
"en-US",
"--to",
"zh-CN",
"fr-FR",
"--fallback-locale",
"en-US",
]);
Expand All @@ -145,12 +152,14 @@ fn convert_to_zh_cn_with_fallback_reports_the_choice() {
String::from_utf8_lossy(&output.stderr)
);
let stdout = String::from_utf8(output.stdout).unwrap();
assert!(stdout.contains("Disable Inspector Recording;"), "{stdout}");
assert!(stdout.contains("Ongoing - Global"), "{stdout}");
assert!(stdout.contains("Disable Inspector Recording"), "{stdout}");
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("fallback-locale spelling") && stderr.contains("global"),
stderr.contains("fallback-locale spelling") && stderr.contains("disableInspector"),
"the fallback choice is visible in tooling output: {stderr}"
);
let _ = std::fs::remove_dir_all(&dir);
}

#[test]
Expand Down
Loading
Loading