Skip to content

Commit

Permalink
feat(cli): Handle cases where system has the 'c' locale as 'en'
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Feb 1, 2023
1 parent 7e0ac93 commit 15a081b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ pub fn commit(repo: Repository, oid: Oid, msg: &str) -> result::Result<Oid, git2
)
}

pub fn lang_to_language(lang: String) -> String {
let re = Regex::new(r"_.*$").unwrap();
String::from(re.replace(lang.as_str(), ""))
pub fn locale_to_language(lang: String) -> String {
let re = Regex::new(r"[-_\.].*$").unwrap();
let locale_frag = lang.as_str().to_lowercase();
let lang = re.replace(&locale_frag, "");
match &lang[..] {
"c" => String::from("en"),
_ => String::from(lang),
}
}

/// Output welcome header at start of run before moving on to actual commands
Expand Down
2 changes: 1 addition & 1 deletion src/make/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn run(target: Vec<String>) -> Result<()> {
.env("CASILE_JOBS", cpus)
.env("CASILEDIR", CONFIGURE_DATADIR)
.env("CONTAINERIZED", status::is_container().to_string())
.env("LANGUAGE", lang_to_language(CONF.get_string("language")?))
.env("LANGUAGE", locale_to_language(CONF.get_string("language")?))
.env("PROJECT", gitname)
.env("PROJECTDIR", CONF.get_string("path")?)
.env("PROJECTVERSION", git_version);
Expand Down

0 comments on commit 15a081b

Please sign in to comment.