Skip to content

Commit

Permalink
Showing 11 changed files with 74 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ jobs:
- run: cargo do version --verbose
- run: cargo do fmt --check
- run: cargo do check
- run: cargo do l10n --all --check
- run: cargo clean
check-macos:
runs-on: macos-latest
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@ jobs:
if: ${{ github.event.inputs.skip_checks != 'true' }}
- run: cargo check --workspace --examples --tests --release
if: ${{ github.event.inputs.skip_checks != 'true' }}
- run: cargo do l10n --all --check
if: ${{ github.event.inputs.skip_checks != 'true' }}
- run: cargo clean
if: ${{ github.event.inputs.skip_checks != 'true' }}
check-windows:
53 changes: 41 additions & 12 deletions crates/cargo-zng/README.md
Original file line number Diff line number Diff line change
@@ -176,35 +176,64 @@ Localization text scraper

See the docs for `l10n!` for more details about the expected format.

Usage: cargo zng l10n [OPTIONS] <INPUT> <OUTPUT>
Usage: cargo zng l10n [OPTIONS]

Arguments:
<INPUT>
Options:
-i, --input <INPUT>
Rust files glob or directory

<OUTPUT>
Lang resources dir
[default: ]

-o, --output <OUTPUT>
L10n resources dir

[default: ]

-p, --package <PACKAGE>
Package to scrap and copy dependencies

If set the --input and --output default is src/**.rs and l10n/

[default: ]

--manifest-path <MANIFEST_PATH>
Path to Cargo.toml of crate to scrap and copy dependencies

If set the --input and --output default to src/**.rs and l10n/

[default: ]

--no-deps
Don't copy dependencies localization

Use with --package or --manifest-path to copy {dep-pkg}/l10n/*.ftl files

Options:
-m, --macros <MACROS>
Custom l10n macro names, comma separated

[default: ]

--pseudo <PSEUDO>
Pseudo Base name, empty to disable
Generate pseudo locale from dir/lang

EXAMPLE

"l10n/en" generates pseudo from "l10n/en.ftl" and "l10n/en/*.ftl"

[default: pseudo]
[default: ]

--pseudo-m <PSEUDO_M>
Pseudo Mirrored name, empty to disable
Generate pseudo mirrored locale

[default: pseudo-mirr]
[default: ]

--pseudo-w <PSEUDO_W>
Pseudo Wide name, empty to disable
Generate pseudo wide locale

[default: ]

[default: pseudo-wide]
--check
Only verify that the generated files are the same

-h, --help
Print help (see a summary with '-h')
16 changes: 11 additions & 5 deletions crates/cargo-zng/src/l10n.rs
Original file line number Diff line number Diff line change
@@ -116,16 +116,22 @@ pub fn run(mut args: L10nArgs) {
fatal!("--output is required for --input")
}

println!(r#"scraping "{input}".."#);
if args.check {
println!(r#"checking "{input}".."#);
} else {
println!(r#"scraping "{input}".."#);
}

let custom_macro_names: Vec<&str> = args.macros.split(',').map(|n| n.trim()).collect();
// let args = ();

let mut template = scraper::scrape_fluent_text(&input, &custom_macro_names);
match template.entries.len() {
0 => println!("did not find any entry"),
1 => println!("found 1 entry"),
n => println!("found {n} entries"),
if !args.check {
match template.entries.len() {
0 => println!("did not find any entry"),
1 => println!("found 1 entry"),
n => println!("found {n} entries"),
}
}

if !template.entries.is_empty() || !template.notes.is_empty() {
2 changes: 1 addition & 1 deletion crates/zng-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ unicase = "2.7"

serde_json = { version = "1.0", optional = true }
breakpad-handler = { version = "0.2", optional = true }
minidump = { version = "0.21", optional = true }
minidump = { version = "0.22", optional = true }
linkme = { version = "=0.3.27", optional = true }
hashbrown = { version = "*", features = ["rayon"] }
rustc-hash = "2.0"
2 changes: 1 addition & 1 deletion crates/zng-view/Cargo.toml
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ features = [
"Win32_System_Shutdown",
]
[target.'cfg(windows)'.dependencies.windows]
version = "0.57.0"
version = "0.58.0"
features = ["Foundation_Collections", "System_UserProfile", "UI_ViewManagement"]

[target.'cfg(windows)'.dependencies]
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ Source: [config/src](./config/src)
cargo do run config
```

Demonstrates the CONFIG service, live updating config between processes.
Demonstrates the CONFIG and SETTINGS services, live updating config between processes.

### `countdown`

@@ -154,7 +154,7 @@ Source: [icon/src](./icon/src)
cargo do run icon
```

Search and copy Material Icons constants.
Search and copy Material Icons keys.

### `image`

Binary file modified examples/button/res/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/config/res/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/localize/res/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions tools/cargo-do/src/main.rs
Original file line number Diff line number Diff line change
@@ -332,7 +332,7 @@ fn doc(mut args: Vec<&str>) {
}
}

// do l10n [-p, --package <pkg>]
// do l10n [-p, --package <pkg>] [--check]
// [--all]
//
// Scrap localization files for publishing. Localization filers are placed in
@@ -353,17 +353,26 @@ fn l10n(mut args: Vec<&str>) {
util::top_cargo_toml("crates")
};

let check = args.iter().any(|a| *a == "--check");

cmd_req("cargo", &["build", "--package", "cargo-zng"], &[]);
let exe = format!("target/debug/cargo-zng{}", std::env::consts::EXE_SUFFIX);
for manifest_path in crates {
let output = std::path::Path::new(&manifest_path).with_file_name("l10n");
if let Err(e) = std::fs::remove_dir_all(&output.join("template")) {
if !matches!(e.kind(), std::io::ErrorKind::NotFound) {
error(f!("cannot clear `{}`, {e}", output.display()));
continue;

if !check {
if let Err(e) = std::fs::remove_dir_all(&output.join("template")) {
if !matches!(e.kind(), std::io::ErrorKind::NotFound) {
error(f!("cannot clear `{}`, {e}", output.display()));
continue;
}
}
}
cmd(&exe, &["zng", "l10n", "--no-deps", "--manifest-path", manifest_path.as_str()], &[]);
cmd(
&exe,
&["zng", "l10n", "--no-deps", "--manifest-path", manifest_path.as_str()],
&args,
);
}
}

0 comments on commit ee29754

Please sign in to comment.