enhance: translate difficulty_name with argument
This commit is contained in:
parent
a5930637c8
commit
48272f17a4
|
@ -41,7 +41,7 @@
|
||||||
"easy": "Easy",
|
"easy": "Easy",
|
||||||
"normal": "Normal",
|
"normal": "Normal",
|
||||||
"hard": "Hard",
|
"hard": "Hard",
|
||||||
"difficulty_name": "Difficulty: ",
|
"difficulty_name": "Difficulty: {difficulty}",
|
||||||
"unknown": "(unknown)"
|
"unknown": "(unknown)"
|
||||||
},
|
},
|
||||||
"coop_menu": {
|
"coop_menu": {
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
"easy": "簡単",
|
"easy": "簡単",
|
||||||
"normal": "普通",
|
"normal": "普通",
|
||||||
"hard": "難しい",
|
"hard": "難しい",
|
||||||
"difficulty_name": "難易度: ",
|
"difficulty_name": "難易度: {difficulty}",
|
||||||
"unknown": "(未知)"
|
"unknown": "(未知)"
|
||||||
},
|
},
|
||||||
"coop_menu": {
|
"coop_menu": {
|
||||||
|
|
|
@ -676,12 +676,7 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
|
||||||
);
|
);
|
||||||
batch.draw(ctx)?;
|
batch.draw(ctx)?;
|
||||||
} else {
|
} else {
|
||||||
fn translate_fallback<'l: 'a, 'a>(
|
fn translate_fallback<'a>(result: &'a str, key: &'_ str, fallback: &'a str) -> &'a str {
|
||||||
loc: &'l Locale,
|
|
||||||
key: &'a str,
|
|
||||||
fallback: &'a str,
|
|
||||||
) -> &'a str {
|
|
||||||
let result = loc.t(key);
|
|
||||||
if result == key {
|
if result == key {
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
@ -689,35 +684,32 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let loc = &state.loc;
|
let loc = &state.loc;
|
||||||
let mut difficulty_name =
|
let difficulty = match save.difficulty {
|
||||||
translate_fallback(loc, "menus.difficulty_menu.difficulty_name", "Difficulty: ")
|
0 => {
|
||||||
.to_owned();
|
let key = "menus.difficulty_menu.normal";
|
||||||
|
translate_fallback(loc.t(key), key, "Normal")
|
||||||
match save.difficulty {
|
}
|
||||||
0 => difficulty_name.push_str(translate_fallback(
|
2 => {
|
||||||
loc,
|
let key = "menus.difficulty_menu.easy";
|
||||||
"menus.difficulty_menu.normal",
|
translate_fallback(loc.t(key), key, "Easy")
|
||||||
"Normal",
|
}
|
||||||
)),
|
4 => {
|
||||||
2 => difficulty_name.push_str(translate_fallback(
|
let key = "menus.difficulty_menu.hard";
|
||||||
loc,
|
translate_fallback(loc.t(key), key, "Hard")
|
||||||
"menus.difficulty_menu.easy",
|
}
|
||||||
"Easy",
|
_ => {
|
||||||
)),
|
let key = "menus.difficulty_menu.unknown";
|
||||||
4 => difficulty_name.push_str(translate_fallback(
|
translate_fallback(loc.t(key), key, "(unknown)")
|
||||||
loc,
|
}
|
||||||
"menus.difficulty_menu.hard",
|
};
|
||||||
"Hard",
|
let diff_key = "menus.difficulty_menu.difficulty_name";
|
||||||
)),
|
let result = loc.tt(diff_key, &[("difficulty", &difficulty)]);
|
||||||
_ => difficulty_name.push_str(translate_fallback(
|
let fallback = "Difficulty: ".to_owned() + &difficulty;
|
||||||
loc,
|
let difficulty_name =
|
||||||
"menus.difficulty_menu.unknown",
|
translate_fallback(&result, diff_key, &fallback);
|
||||||
"(unknown)",
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
|
|
||||||
state.font.builder().position(self.x as f32 + 20.0, y + 10.0).draw(
|
state.font.builder().position(self.x as f32 + 20.0, y + 10.0).draw(
|
||||||
difficulty_name.as_str(),
|
difficulty_name,
|
||||||
ctx,
|
ctx,
|
||||||
&state.constants,
|
&state.constants,
|
||||||
&mut state.texture_set,
|
&mut state.texture_set,
|
||||||
|
|
Loading…
Reference in New Issue