mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
langtool: cargo fmt
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0164UKoXpz9r155TRfQsoc3H
This commit is contained in:
1 parent
77e356961d
commit
9398629ddf
3 files changed
+43
-42
No files matched your search
+11
-14
@@ -673,8 +673,7 @@ fn execute_command(cmd: Command, ai: Option<&Ai>, dry_run: bool, verbose: bool)
|
||||
let root = "../../assets/lang";
|
||||
let reference_ini_filename = "en_US.ini";
|
||||
|
||||
let reference_ini =
|
||||
IniFile::parse_file(&format!("{root}/{reference_ini_filename}")).unwrap();
|
||||
let reference_ini = IniFile::parse_file(&format!("{root}/{reference_ini_filename}")).unwrap();
|
||||
|
||||
let mut filenames = Vec::new();
|
||||
if filenames.is_empty() {
|
||||
@@ -801,11 +800,15 @@ fn execute_command(cmd: Command, ai: Option<&Ai>, dry_run: bool, verbose: bool)
|
||||
language: _,
|
||||
section: _,
|
||||
} => {}
|
||||
Command::FixupRefKeys => if is_reference {
|
||||
fixup_keys(&target_ini, dry_run).unwrap();
|
||||
Command::FixupRefKeys => {
|
||||
if is_reference {
|
||||
fixup_keys(&target_ini, dry_run).unwrap();
|
||||
}
|
||||
}
|
||||
Command::CheckRefKeys => if is_reference {
|
||||
check_keys(&target_ini).unwrap();
|
||||
Command::CheckRefKeys => {
|
||||
if is_reference {
|
||||
check_keys(&target_ini).unwrap();
|
||||
}
|
||||
}
|
||||
Command::CopyMissingLines {
|
||||
dont_comment_missing,
|
||||
@@ -916,14 +919,8 @@ fn execute_command(cmd: Command, ai: Option<&Ai>, dry_run: bool, verbose: bool)
|
||||
} else {
|
||||
if ai_response.is_some() {
|
||||
let _ = extra;
|
||||
add_new_key(
|
||||
&mut target_ini,
|
||||
section,
|
||||
key,
|
||||
value,
|
||||
overwrite_translated,
|
||||
)
|
||||
.unwrap();
|
||||
add_new_key(&mut target_ini, section, key, value, overwrite_translated)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,22 +29,22 @@ pub fn line_value(line: &str) -> Option<&str> {
|
||||
}
|
||||
|
||||
impl Section {
|
||||
pub fn apply_regex(&mut self, key: &str, pattern: &str, replacement: &str) {
|
||||
let re = Regex::new(pattern).unwrap();
|
||||
for line in self.lines.iter_mut() {
|
||||
let prefix = if let Some(pos) = line.find(" =") {
|
||||
&line[0..pos]
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
if prefix.eq(key) {
|
||||
if let Some((_, value)) = split_line(line) {
|
||||
let new_value = re.replace_all(value, replacement);
|
||||
*line = format!("{} = {}", key, new_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn apply_regex(&mut self, key: &str, pattern: &str, replacement: &str) {
|
||||
let re = Regex::new(pattern).unwrap();
|
||||
for line in self.lines.iter_mut() {
|
||||
let prefix = if let Some(pos) = line.find(" =") {
|
||||
&line[0..pos]
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
if prefix.eq(key) {
|
||||
if let Some((_, value)) = split_line(line) {
|
||||
let new_value = re.replace_all(value, replacement);
|
||||
*line = format!("{} = {}", key, new_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_line(&mut self, key: &str) -> Option<String> {
|
||||
let mut remove_index = None;
|
||||
@@ -203,16 +203,26 @@ impl Section {
|
||||
let right_part = line.strip_prefix(&prefix).unwrap().to_string();
|
||||
if let Some(pos) = key.find('(') {
|
||||
let key_name = key[0..pos].trim();
|
||||
let key_desc = key[pos+1..key.len()-1].trim();
|
||||
let key_desc = key[pos + 1..key.len() - 1].trim();
|
||||
if let Some(pos) = right_part.find('(') {
|
||||
let value_name = right_part[0..pos].trim();
|
||||
let value_desc = right_part[pos+1..right_part.len()-1].trim();
|
||||
let value_desc = right_part[pos + 1..right_part.len() - 1].trim();
|
||||
self.insert_line_if_missing(&format!("{} = {}", key_name, value_name));
|
||||
self.insert_line_if_missing(&format!("{} = {}", Self::capitalize_first_letter(key_desc), Self::capitalize_first_letter(value_desc)));
|
||||
self.insert_line_if_missing(&format!(
|
||||
"{} = {}",
|
||||
Self::capitalize_first_letter(key_desc),
|
||||
Self::capitalize_first_letter(value_desc)
|
||||
));
|
||||
} else {
|
||||
println!("split_key: didn't find '(' in the value part {right_part} for key {key}. Leaving description untranslated.");
|
||||
println!(
|
||||
"split_key: didn't find '(' in the value part {right_part} for key {key}. Leaving description untranslated."
|
||||
);
|
||||
self.insert_line_if_missing(&format!("{} = {}", key_name, right_part.trim()));
|
||||
self.insert_line_if_missing(&format!("{} = {}", Self::capitalize_first_letter(key_desc), Self::capitalize_first_letter(key_desc)));
|
||||
self.insert_line_if_missing(&format!(
|
||||
"{} = {}",
|
||||
Self::capitalize_first_letter(key_desc),
|
||||
Self::capitalize_first_letter(key_desc)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
println!("split_key: didn't find '(' in the key {key}");
|
||||
|
||||
@@ -28,13 +28,7 @@ pub fn ask_letter(question: &str, allowed_chars: &str) -> char {
|
||||
.read_line(&mut input)
|
||||
.expect("Failed to read line");
|
||||
|
||||
match input
|
||||
.trim()
|
||||
.to_lowercase()
|
||||
.as_str()
|
||||
.chars()
|
||||
.next()
|
||||
{
|
||||
match input.trim().to_lowercase().as_str().chars().next() {
|
||||
Some(c) => {
|
||||
if allowed_chars.contains(c) {
|
||||
return c;
|
||||
|
||||
Reference in new issue
Block a user