Skip to content

Commit

Permalink
translation utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett committed Feb 19, 2019
1 parent 56fb6d0 commit b05ce4e
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 3 deletions.
59 changes: 59 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[package]
name = "hemtt"
version = "0.4.1"
version = "0.5.0"
authors = ["Brett <brett@bmandesigns.com>"]
edition = "2018"

[dependencies]
armake2 = { git = "https://github.com/KoffeinFlummi/armake2", branch="master" }
colored = "1.7"
docopt = "1"
pbr = "1.0"
reqwest = "0.9"
self_update = "0.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde-xml-rs = "0.3.1"
walkdir = "2.2"

[target.'cfg(windows)'.dependencies]
Expand Down
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
* [Getting Started](/getting_started.md)
* [HEMTT.json Project File](/json.md)
* [Usage](/usage.md)
* [Utilities](/utilities.md)
12 changes: 11 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Usage:
hemtt <a href="/HEMTT/#/usage?id=init">init</a>
hemtt <a href="/HEMTT/#/usage?id=create">create</a>
hemtt <a href="/HEMTT/#/usage?id=addon">addon</a> &lt;name&gt;
hemtt <a href="/HEMTT/#/usage?id=build">build</a> [--release] [--force] [--nowarn]
hemtt <a href="/HEMTT/#/usage?id=build">build</a> [<a href="/HEMTT/#/usage?id=-release">--release</a>] [<a href="/HEMTT/#/usage?id=-force-f">--force</a>] [<a href="/HEMTT/#/usage?id=-nowarn">--nowarn</a>]
hemtt <a href="/HEMTT/#/usage?id=clean">clean</a> [--force]
hemtt <a href="/HEMTT/#/usage?id=run">run</a> &lt;utility&gt;
hemtt <a href="/HEMTT/#/usage?id=update">update</a>
hemtt (-h | --help)
hemtt --version
Expand Down Expand Up @@ -104,6 +106,14 @@ would produce
This example is from the [HEMTT Example Project](https://github.com/synixebrett/HEMTT-Example)
<hr/>

# clean
Cleans all the files generated from previous builds.
<hr>

# run
Run a [Utility](/utilities.md).
<hr/>

# update

HEMTT will look for a more recent version online. If one is available you will be prompted to download the updated version.
25 changes: 25 additions & 0 deletions docs/utilities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Utilities

# translation

The translation utility will scan your project for `stringtable.xml` files and will tally up the keys. It will display a table with the key counts and the completion percentage. Supports all [Arma 3 Languages](https://community.bistudio.com/wiki/Stringtable.xml#Supported_languages).

`./hemtt run translation`
```
Total 2698
English 2698 100%
Italian 2677 99%
Polish 2677 99%
Japanese 2647 98%
Chinese 2609 97%
Chinesesimp 2601 96%
German 2529 94%
Korean 2471 92%
French 2451 91%
Russian 2178 81%
Czech 2085 77%
Portuguese 2067 77%
Spanish 2015 75%
Hungarian 1558 58%
Turkish 3 0%
```
18 changes: 18 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod build;
mod error;
mod files;
mod project;
mod utilities;

use crate::error::*;

Expand All @@ -30,6 +31,7 @@ Usage:
hemtt addon <name>
hemtt build [--release] [--force] [--nowarn]
hemtt clean [--force]
hemtt run <utility>
hemtt update
hemtt (-h | --help)
hemtt --version
Expand Down Expand Up @@ -57,13 +59,20 @@ struct Args {
cmd_addon: bool,
cmd_build: bool,
cmd_clean: bool,
cmd_run: bool,
cmd_update: bool,
flag_verbose: bool,
flag_force: bool,
flag_nowarn: bool,
flag_version: bool,
flag_release: bool,
arg_name: String,
arg_utility: Option<Utility>
}

#[derive(Debug, Deserialize)]
enum Utility {
Translation
}

fn input(text: &str) -> String {
Expand Down Expand Up @@ -149,6 +158,15 @@ fn run_command(args: &Args) -> Result<(), Error> {
files::clear_releases().unwrap();
}
Ok(())
} else if args.cmd_run {
if let Some(utility) = &args.arg_utility {
match utility {
Utility::Translation => {
utilities::translation::check().unwrap();
}
}
}
Ok(())
} else if args.cmd_update {
let target = self_update::get_target().unwrap();
let status = self_update::backends::github::Update::configure().unwrap()
Expand Down
6 changes: 5 additions & 1 deletion src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ pub fn get_version() -> Result<String, std::io::Error> {
_ => {}
}
}
version = format!("{}.{}.{}.{}", major, minor, patch, build);
if build == "" {
version = format!("{}.{}.{}", major, minor, patch);
} else {
version = format!("{}.{}.{}.{}", major, minor, patch, build);
}
}
Ok(version)
}
Expand Down
1 change: 1 addition & 0 deletions src/utilities/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod translation;
Loading

0 comments on commit b05ce4e

Please sign in to comment.