-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
155 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
mod lang; | ||
|
||
use std::{env::current_exe, process::ExitCode}; | ||
|
||
use junowen_lib::{hook_utils::do_dll_injection, lang::Lang}; | ||
use sys_locale::get_locales; | ||
|
||
use crate::lang::to_lang_source; | ||
|
||
fn create_lang() -> Lang { | ||
let lang = get_locales() | ||
.flat_map(|tag| { | ||
let primary_lang = tag.split('-').next().unwrap_or(&tag).to_owned(); | ||
[tag, primary_lang] | ||
}) | ||
.filter_map(|tag| to_lang_source(&tag)) | ||
.find_map(|file| toml::from_str(file).ok()) | ||
.unwrap_or_default(); | ||
Lang::new(lang) | ||
} | ||
|
||
fn main() -> ExitCode { | ||
let lang = create_lang(); | ||
|
||
let dll_path = current_exe() | ||
.unwrap() | ||
.as_path() | ||
.parent() | ||
.unwrap() | ||
.join(concat!(env!("CARGO_PKG_NAME"), ".dll")); | ||
if let Err(err) = do_dll_injection("th19.exe", &dll_path) { | ||
lang.print("failed injection into th19.exe"); | ||
println!(": {}", err); | ||
println!(); | ||
lang.println("you can close this window by pressing enter..."); | ||
let _ = std::io::stdin().read_line(&mut String::new()); | ||
return ExitCode::FAILURE; | ||
} | ||
|
||
lang.println("completed injection into th19.exe"); | ||
println!(); | ||
lang.println("you can close this window by pressing enter..."); | ||
let _ = std::io::stdin().read_line(&mut String::new()); | ||
ExitCode::SUCCESS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"failed injection into th19.exe" = "th19.exe への注入に失敗しました" | ||
"completed injection into th19.exe" = "th19.exe への注入が完了しました" | ||
"you can close this window by pressing enter..." = "エンターキーを押してこのウィンドウを閉じることができます..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub fn to_lang_source(tag: &str) -> Option<&'static str> { | ||
match tag { | ||
"ja" => Some(include_str!("ja.toml")), | ||
_ => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.